-
Notifications
You must be signed in to change notification settings - Fork 0
Editor Scripts
This documentation will guide you how to use the HorangHill Editor Scripts properly. Editor script is a way to add things that are not provided by the editor GUI by running a script provided by the user. Be careful when running editor scripts from the internet as they can cause harm to your device. To open the editor script, click on the toolbar item with the script icon.
debug("Hello, world!");
It will write the message in the editor log which can be opened by clicking the console symbol in the editor toolbar.
spawnCube(
0, //X Position
1, //Y Position
0, //Z Position
1, //X Size
1, //Y Size
1, // Z Size
0xff0000 //Color
)
This script will spawn a cube with a coordinate of (0, 1, 0), a size of (1, 1, 1) and a red hex color.
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
spawnCube(
Math.floor(Math.random() * 5), //X Position
Math.floor(Math.random() * 5), //Y Position
Math.floor(Math.random() * 5), //Z Position
Math.floor(Math.random() * 5), //X Size
Math.floor(Math.random() * 5), //Y Size
Math.floor(Math.random() * 5), // Z Size
getRandomColor(), //Color
)
This will spawn a cube with completely random properties.
addSphere(
x,
y,
z,
radius,
widthSegments,
heightSegments,
color
)
This will spawn a sphere in the scene
addCone(
x,
y,
z,
radius,
height,
radialSegments,
color
)
This will spawn a cone in the scene
addCylinder(
x,
y,
z,
radiusTop,
radiusBottom,
height,
radialSegments,
color
)
addLight(
x,
y,
z,
intensity,
distance,
color
)
This will spawn a light in the scene
generateterrain(
voxsize,
tersize,
color
)
This will randomly generete a terrain using ImprovedNoise and put it in the scene
const dirLight = new THREE.DirectionalLight(0xffffff, 1);
dirLight.color.setHSL(0.1, 1, 0.95);
dirLight.position.set(- 1, 1.75, 1);
dirLight.position.multiplyScalar(30);
scene.add(dirLight);
dirLight.castShadow = true;
dirLight.shadow.mapSize.width = 2048;
dirLight.shadow.mapSize.height = 2048;
const d = 50;
dirLight.shadow.camera.left = - d;
dirLight.shadow.camera.right = d;
dirLight.shadow.camera.top = d;
dirLight.shadow.camera.bottom = - d;
dirLight.shadow.camera.far = 3500;
dirLight.shadow.bias = - 0.0001;
As you might already know, Horanghill Editor lacked an advanced lighting system due to performance issues, But if you really want to feel like using an RTX 6990 then this is for you. This will create an epix lighting system (need rtx 6990 to run)
scene.background = new THREE.Color( 0x005A9C);
This will change the skybox to a light blue color