Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ShadowGenerator,
DirectionalLight,
Color4,
CSG,
Animation,
AnimationEvent,
Sound,
} from 'babylonjs';
import CANNON from 'cannon';
window.CANNON = CANNON;
const canvas = document.getElementById("stage");
const engine = new Engine(canvas, true);
const scene = new Scene(engine);
const light = new HemisphericLight("light", new Vector3(0, 3, 0), scene);
let started = false;
let renderScene = true;
let shift = 0;
light.intensity = 2.5;
const camera = new FreeCamera("FreeCamera",new Vector3(0, 4, -22), scene);
camera.setTarget(new Vector3(0, 1, 0));
const sphere = MeshBuilder.CreateSphere("ball", {
diameter: 0.6
}, scene);
sphere.position.z = -17;
sphere.position.y = 0.7;
const boxes=[];
let sceneAnimations = [];
let currentBox;
// droping animation
10,
BABYLON.Vector3.Zero(),
this.scene
);
// This targets the camera to scene origin
this.camera.setTarget(BABYLON.Vector3.Zero());
// This attaches the camera to the canvas
this.camera.attachControl(this.canvas, true);
this.camera.setPosition(new BABYLON.Vector3(500, 400, -100));
this.camera.useAutoRotationBehavior = true;
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new BABYLON.HemisphericLight(
"global_light",
new BABYLON.Vector3(0, 1, 0),
this.scene
);
light.intensity = 0.7;
}
initScene() {
this.scene.clearColor = new BABYLON.Color3(0.7, 0.7, 0.7);
// This creates and positions a free camera (non-mesh)
this.camera = new BABYLON.ArcRotateCamera('camera', 0, 0, 10, BABYLON.Vector3.Zero(), this.scene);
// This targets the camera to scene origin
this.camera.setTarget(BABYLON.Vector3.Zero());
// This attaches the camera to the canvas
this.camera.attachControl(this.canvas, true);
this.camera.setPosition(new BABYLON.Vector3(500, 400, -100));
this.camera.useAutoRotationBehavior = true;
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new BABYLON.HemisphericLight('global_light', new BABYLON.Vector3(0, 1, 0), this.scene);
light.intensity = 0.8;
}
addLights() {
const light = new HemisphericLight(
'light',
new Vector3(0, 1, 0),
this._scene
);
light.intensity = 1;
}
setCamera(){
const camera = new BABYLON.ArcRotateCamera("camera", 0, 1, 20, BABYLON.Vector3.Zero(), this.scene);
camera.setTarget(new BABYLON.Vector3(0, 4, 0));
camera.setPosition(new BABYLON.Vector3(0, 5, 11))
camera.attachControl(this.canvas, true);
const light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), this.scene);
light.intensity = 0.7;
return camera;
}
setCamera(){
const camera = new BABYLON.ArcRotateCamera("camera", 0, 1, 20, BABYLON.Vector3.Zero(), this.scene);
camera.setTarget(new BABYLON.Vector3(0, 4, 0));
camera.setPosition(new BABYLON.Vector3(0, 6, 12))
camera.attachControl(this.canvas, true);
const light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), this.scene);
light.intensity = 0.7;
return camera;
}