How to use the babylonjs.Scene function in babylonjs

To help you get started, we’ve selected a few babylonjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rodrigo-brito / gocity / ui / src / Scene.js View on Github external
componentDidMount() {
    if (this.state.support) {
      this.engine = new BABYLON.Engine(this.canvas, true, {
        preserveDrawingBuffer: true,
        stencil: true
      });

      this.scene = new BABYLON.Scene(this.engine);

      if (typeof this.props.onSceneMount === "function") {
        this.props.onSceneMount({
          scene: this.scene,
          engine: this.engine,
          canvas: this.canvas
        });
      } else {
        console.error("onSceneMount function not available");
      }

      // Resize the babylon engine when the window is resized
      window.addEventListener("resize", this.onResizeWindow);
    } else {
      swal(
        'Browser not supported',
github cassieview / Build-First-Web-VR-Game-Absolute-Beginner / src / index.ts View on Github external
function createScene(): Scene {
    // Create scene
    var scene: Scene = new Scene(engine);
    var sphereLight = new DirectionalLight("dir02", new Vector3(0.2, -1, 0), scene);
    sphereLight.position = new Vector3(0, 80, 0);
    var gravityVector = new BABYLON.Vector3(0, -1, 0);
    scene.enablePhysics(gravityVector, new CannonJSPlugin);

    scene.clearColor = BABYLON.Color4.FromColor3(BABYLON.Color3.Black());

    var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -10), scene);
    //var camera = new BABYLON.UniversalCamera("UniversalCamera", new BABYLON.Vector3(0, 0, -10), scene);
    camera.checkCollisions = true;
    camera.applyGravity = true;
    // Targets the camera to a particular position. In this case the scene origin
    camera.setTarget(BABYLON.Vector3.Zero());

    // Attach the camera to the canvas
    camera.attachControl(canvas, true);
github mishig25 / 3d-posenet / graphics.js View on Github external
initScene(){
        this.scene = new BABYLON.Scene(this.engine);
        this.scene.clearColor = new BABYLON.Color3(0.5, 0.8, 0.5);
        const camera = this.setCamera();
        const sphere = BABYLON.MeshBuilder.CreateSphere('', { diameter: .0001 }, this.scene);
        BABYLON.SceneLoader.ImportMesh("", "/dist/Scenes/Dude/", "Dude.babylon", this.scene, (newMeshes, particleSystems, skeletons) => {
            const mesh = newMeshes[0];
            const skeleton = skeletons[0];
            mesh.scaling = new BABYLON.Vector3(0.1, 0.1, 0.1);
            mesh.position = new BABYLON.Vector3(0, 0, 0);

            const head_bone = skeleton.bones[7];
            const right_shoulder_bone = skeleton.bones[13];
            const right_arm_bone = skeleton.bones[14];
            const left_shoulder_bone = skeleton.bones[32];
            const left_arm_bone = skeleton.bones[33];

            const lookAtCtl = new BABYLON.BoneLookController(mesh, head_bone, sphere.position, { adjustYaw: Math.PI * .5, adjustRoll: Math.PI * .5 });
github springtype-org / springtype / e2e / babylon-3d / src / component / first-scene / first-scene.tsx View on Github external
private createScene() {
        this.scene = new Scene(this.engine);
        this.scene.clearColor = new Color4(0, 0, 0, 0);
    }
github springtype-org / springtype / src / packages / cli / springtype / template / project / babylon-3d / src / component / first-scene / first-scene.tsx View on Github external
private createScene() {
        this.scene = new Scene(this.engine);
        this.scene.clearColor = new Color4(0, 0, 0, 0);
    }
github brochington / Akkad / src / actions / SceneActions.js View on Github external
setScene(state, actions, sceneID, canvas) {
        const canvasID = `canvas-${sceneID}`;
        const engineID = `engine-${sceneID}`;

        const engine = new Babylon.Engine(canvas, true);
        const scene = new Babylon.Scene(engine);

        const newState = state()
                .setIn(["entities", canvasID], Immutable.Map({
                    id: canvasID,
                    entity: canvas,
                    type: "canvas"
                }))
                .setIn(["entities", engineID], Immutable.Map({
                    id: engineID,
                    entity: engine,
                    type: "engine"
                }))
                .setIn(["entities", sceneID], Immutable.Map({
                    id: sceneID,
                    entity: scene,
                    type: "scene"
github rodrigo-brito / gocity / ui / src / App.js View on Github external
reset() {
    this.scene.dispose();
    this.scene = new BABYLON.Scene(this.engine);
    this.initScene();
  }