예제 #1
0
파일: Main.cs 프로젝트: ARLM-Attic/babylon
        private void Scene2()
        {
            // This creates and positions a free camera
            var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), this.scene);

            // This targets the camera to scene origin
            camera.setTarget(BABYLON.Vector3.Zero());

            // This creates a light, aiming 0,1,0 - to the sky.
            var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), this.scene);

            // Dim the light a small amount
            light.intensity = .5;

            // Let's try our built-in 'sphere' shape. Params: name, subdivisions, size, scene
            var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, this.scene);

            // Move the sphere upward 1/2 its height
            sphere.position.y = 1;

            // Let's try our built-in 'ground' shape.  Params: name, width, depth, subdivisions, scene
            BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, this.scene);

            // Attach the camera to the scene
            scene.activeCamera.attachControl(canvas);
        }
예제 #2
0
파일: Main.cs 프로젝트: ARLM-Attic/babylon
        private void Scene10()
        {
            this.scene = new BABYLON.Scene(engine);
            var camera  = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -20), scene);
            var light   = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 2), scene);
            var sphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 3, scene);
            var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 16, 3, scene);
            var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 16, 3, scene);

            var material0 = new BABYLON.StandardMaterial("mat0", scene);

            material0.diffuseColor = new BABYLON.Color3(1, 0, 0);
            sphere0.material       = material0;
            sphere0.position       = new BABYLON.Vector3(-10, 0, 0);

            var material1 = new BABYLON.StandardMaterial("mat1", scene);

            material1.diffuseColor = new BABYLON.Color3(1, 1, 0);
            sphere1.material       = material1;

            var material2 = new BABYLON.StandardMaterial("mat2", scene);

            material2.diffuseColor = new BABYLON.Color3(1, 0, 1);
            sphere2.material       = material2;
            sphere2.position       = new BABYLON.Vector3(10, 0, 0);

            sphere1.convertToFlatShadedMesh();

            camera.setTarget(new BABYLON.Vector3(0, 0, 0));

            // Fog
            scene.fogMode    = BABYLON.Scene.FOGMODE_EXP;
            scene.fogDensity = 0.1;

            // Animations
            var alpha = 0.0;

            scene.registerBeforeRender(() =>
            {
                sphere0.position.z = 4 * Math.Cos(alpha);
                sphere1.position.z = 4 * Math.Sin(alpha);
                sphere2.position.z = 4 * Math.Cos(alpha);

                alpha += 0.1;
            });

            this.scene.activeCamera.attachControl(this.canvas);
        }