コード例 #1
0
 protected void CreateTrackball()
 {
     controls                      = new THREE.TrackballControls(camera, renderer.domElement);
     controls.rotateSpeed          = 4.0;
     controls.zoomSpeed            = 1.2;
     controls.panSpeed             = 0.8;
     controls.noZoom               = false;
     controls.noPan                = false;
     controls.staticMoving         = true;
     controls.dynamicDampingFactor = 0.3;
 }
コード例 #2
0
 private void CreateTrackballControl()
 {
     controls                      = new THREE.TrackballControls(camera);
     controls.rotateSpeed          = 3.0;
     controls.zoomSpeed            = 1.2;
     controls.panSpeed             = 0.8;
     controls.noZoom               = false;
     controls.noPan                = false;
     controls.staticMoving         = true;
     controls.dynamicDampingFactor = 0.3;
 }
コード例 #3
0
        public override void Init()
        {
            var width  = Width;
            var height = Height;


            var info = Document.CreateElement("div");

            info.InnerHTML = "Drag to change the view";
            Container.AppendChild(info);

            camera            = new THREE.PerspectiveCamera(70, width / height, 1, 1000);
            camera.position.y = 150;
            camera.position.z = 500;

            controls = new THREE.TrackballControls(camera);

            scene = new THREE.Scene();

            THREE.PointLight light = new THREE.PointLight(0xffffff);
            light.position.set(500, 500, 500);
            scene.add(light);



            THREE.MeshLambertMaterial mat = new THREE.MeshLambertMaterial();


            mat.shading = THREE.ShadingType.FlatShading;



            sphere = new THREE.Mesh(new THREE.SphereGeometry(200, 20, 10), mat);
            scene.add(sphere);

            THREE.MeshBasicMaterial mat2 = new THREE.MeshBasicMaterial();
            mat2.color = 0xe0e0e0;


            THREE.Mesh plane = new THREE.Mesh(new THREE.PlaneBufferGeometry(400, 400), mat2);
            plane.position.y = -200;
            plane.rotation.x = -Math.PI / 2;
            scene.add(plane);

            renderer = new THREE.CanvasRenderer();
            renderer.setClearColor(0xf0f0f0);
            renderer.setSize(width, height);

            effect = new THREE.AsciiEffect(renderer, " +-Hgxyz");
            effect.setSize(width, height);
            Container.AppendChild(effect.domElement);
        }
コード例 #4
0
        public override void Init()
        {
            var width = Width;
            var height = Height;

            var info = Document.CreateElement("div");
            info.InnerHTML = "Drag to change the view";
            Container.AppendChild(info);

            camera = new THREE.PerspectiveCamera(70, width / height, 1, 1000);
            camera.position.y = 150;
            camera.position.z = 500;

            controls = new THREE.TrackballControls(camera);

            scene = new THREE.Scene();

            THREE.PointLight light = new THREE.PointLight(0xffffff);
            light.position.set(500, 500, 500);
            scene.add(light);

            THREE.MeshLambertMaterial mat = new THREE.MeshLambertMaterial();

            mat.shading = THREE.ShadingType.FlatShading;

            sphere = new THREE.Mesh(new THREE.SphereGeometry(200, 20, 10), mat);
            scene.add(sphere);

            THREE.MeshBasicMaterial mat2 = new THREE.MeshBasicMaterial();
            mat2.color = 0xe0e0e0;

            THREE.Mesh plane = new THREE.Mesh(new THREE.PlaneBufferGeometry(400, 400), mat2);
            plane.position.y = -200;
            plane.rotation.x = -Math.PI / 2;
            scene.add(plane);

            renderer = new THREE.CanvasRenderer();
            renderer.setClearColor(0xf0f0f0);
            renderer.setSize(width, height);

            effect = new THREE.AsciiEffect(renderer, " +-Hgxyz");
            effect.setSize(width, height);
            Container.AppendChild(effect.domElement);
        }
コード例 #5
0
 private void CreateTrackball()
 {
     controls = new THREE.TrackballControls(camera,renderer.domElement);
     controls.rotateSpeed = 4.0;
     controls.zoomSpeed = 1.2;
     controls.panSpeed = 0.8;
     controls.noZoom = false;
     controls.noPan = false;
     controls.staticMoving = true;
     controls.dynamicDampingFactor = 0.3;
 }
コード例 #6
0
        public override void Init()
        {
            base.Init();

            controls = new THREE.TrackballControls(camera, Container);

            controls.rotateSpeed = 3.0;
            controls.zoomSpeed = 1.2;
            controls.panSpeed = 0.8;

            controls.noZoom = false;
            controls.noPan = false;

            controls.staticMoving = true;
            controls.dynamicDampingFactor = 0.3;

            controls.keys = new int[] { 65, 83, 68 };

            scene = new THREE.Scene();
               // THREE.FogExp2 fg2 = new THREE.FogExp2(new THREE.Color().setHex(0xcccccc), 0.002);

            THREE.FogExp2 fg2 = new THREE.FogExp2(0xcccccc, 0.002);
            scene.fog = fg2;

            var geometry = new THREE.CylinderGeometry(0, 10, 30, 4, 1);
            var material = new THREE.MeshPhongMaterial();

            material.color = new THREE.Color().setHex(0xffffff); // 0xffffff;
            material.shading = THREE.ShadingType.FlatShading;

            for (var i = 0; i < 500; i++)
            {

                var mesh = new THREE.Mesh(geometry, material);
                mesh.position.x = (Math.Random() - 0.5) * 1000;
                mesh.position.y = (Math.Random() - 0.5) * 1000;
                mesh.position.z = (Math.Random() - 0.5) * 1000;
                mesh.updateMatrix();
                mesh.matrixAutoUpdate = false;
                scene.add(mesh);

            }

            // lights

            THREE.Light light = new THREE.DirectionalLight();
            light.color = new THREE.Color().setHex(0xffffff);
            light.position.set(1, 1, 1);
            scene.add(light);

            light = new THREE.DirectionalLight();
            light.color = new THREE.Color().setHex(0x002288);
            light.position.set(-1, -1, -1);
            scene.add(light);

            light = new THREE.AmbientLight(0x222222);
            light.color = new THREE.Color().setHex(0x222222);
            scene.add(light);

            // renderer

            renderer = new THREE.WebGLRenderer(false);
            renderer.antialias = false;
            renderer.setClearColor(scene.fog.color);
            //TODO: renderer.setPixelRatio( Window.devicePixelRatio );
            renderer.setSize(Width, Height);

            Container.AppendChild(renderer.domElement);

            //stats = new Stats();
            //stats.domElement.style.position = 'absolute';
            //stats.domElement.style.top = '0px';
            //stats.domElement.style.zIndex = 100;
            //container.appendChild( stats.domElement );

            //

            //
        }
コード例 #7
0
        public override void Init()
        {
            base.Init();

            controls = new THREE.TrackballControls(camera, Container);

            controls.rotateSpeed = 3.0;
            controls.zoomSpeed   = 1.2;
            controls.panSpeed    = 0.8;

            controls.noZoom = false;
            controls.noPan  = false;

            controls.staticMoving         = true;
            controls.dynamicDampingFactor = 0.3;

            controls.keys = new int[] { 65, 83, 68 };


            scene = new THREE.Scene();
            // THREE.FogExp2 fg2 = new THREE.FogExp2(new THREE.Color().setHex(0xcccccc), 0.002);

            THREE.FogExp2 fg2 = new THREE.FogExp2(0xcccccc, 0.002);
            scene.fog = fg2;


            var geometry = new THREE.CylinderGeometry(0, 10, 30, 4, 1);
            var material = new THREE.MeshPhongMaterial();

            material.color   = new THREE.Color().setHex(0xffffff); // 0xffffff;
            material.shading = THREE.ShadingType.FlatShading;


            for (var i = 0; i < 500; i++)
            {
                var mesh = new THREE.Mesh(geometry, material);
                mesh.position.x = (Math.Random() - 0.5) * 1000;
                mesh.position.y = (Math.Random() - 0.5) * 1000;
                mesh.position.z = (Math.Random() - 0.5) * 1000;
                mesh.updateMatrix();
                mesh.matrixAutoUpdate = false;
                scene.add(mesh);
            }


            // lights

            THREE.Light light = new THREE.DirectionalLight();
            light.color = new THREE.Color().setHex(0xffffff);
            light.position.set(1, 1, 1);
            scene.add(light);

            light       = new THREE.DirectionalLight();
            light.color = new THREE.Color().setHex(0x002288);
            light.position.set(-1, -1, -1);
            scene.add(light);

            light       = new THREE.AmbientLight(0x222222);
            light.color = new THREE.Color().setHex(0x222222);
            scene.add(light);


            // renderer

            renderer           = new THREE.WebGLRenderer(false);
            renderer.antialias = false;
            renderer.setClearColor(scene.fog.color);
            //TODO: renderer.setPixelRatio( Window.devicePixelRatio );
            renderer.setSize(Width, Height);

            Container.AppendChild(renderer.domElement);

            //stats = new Stats();
            //stats.domElement.style.position = 'absolute';
            //stats.domElement.style.top = '0px';
            //stats.domElement.style.zIndex = 100;
            //container.appendChild( stats.domElement );

            //


            //
        }
コード例 #8
0
        public override void Init()
        {
            // create a scene, that will hold all our elements such as objects, cameras and lights.
            scene = new THREE.Scene();

            // create a camera, which defines where we're looking at.
            camera = new THREE.PerspectiveCamera(45, Width / Height, 0.1, 1000);

            // create a render and set the size
            renderer = new THREE.WebGLRenderer();

            renderer.setClearColor(new THREE.Color(0xEEEEEE));
            renderer.setSize(Width, Height);
            renderer.shadowMapEnabled = true;
            // add the output of the renderer to the html element
            Container.AppendChild(renderer.domElement);

            // create the ground plane
            var planeGeometry = new THREE.PlaneGeometry(60, 20);
            var planeMaterial = new THREE.MeshLambertMaterial();
            planeMaterial.color = new THREE.Color(0.9, 0.9, 0.9);
            var plane = new THREE.Mesh(planeGeometry, planeMaterial);
            plane.receiveShadow = true;

            // rotate and position the plane
            plane.rotation.x = -0.5 * Math.PI;
            plane.position.x = 15;
            plane.position.y = 0;
            plane.position.z = 0;

            // add the plane to the scene
            scene.add(plane);

            // create a cube
            var cubeGeometry = new THREE.CubeGeometry(4, 4, 4);
            var cubeMaterial = new THREE.MeshLambertMaterial(); // { color = 0xff0000 };
            cubeMaterial.color = new THREE.Color(1, 0, 0);
            var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
            cube.castShadow = true;

            // position the cube
            cube.position.x = -4;
            cube.position.y = 3;
            cube.position.z = 0;

            // add the cube to the scene
            scene.add(cube);

            var sphereGeometry = new THREE.SphereGeometry(4, 20, 20);
            var sphereMaterial = new THREE.MeshLambertMaterial(); // { color = 0x7777ff };
            sphereMaterial.color = new THREE.Color(0, 0, 1);
            var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);

            // position the sphere
            sphere.position.x = 20;
            sphere.position.y = 4;
            sphere.position.z = 2;
            sphere.castShadow = true;

            // add the sphere to the scene
            scene.add(sphere);

            // position and point the camera to the center of the scene
            camera.position.x = -30;
            camera.position.y = 40;
            camera.position.z = 30;
            camera.lookAt(scene.position);

            // add spotlight for the shadows
            var spotLight = new THREE.SpotLight(); //0xffffff);
            spotLight.color = new THREE.Color(1, 1, 1);
            spotLight.position.set(-40, 60, -10);
            spotLight.castShadow = true;
            scene.add(spotLight);

            controls = new THREE.TrackballControls(camera);

            controls.rotateSpeed = 10.0;
            controls.zoomSpeed = 1.2;
            controls.panSpeed = 0.8;

            controls.noZoom = false;
            controls.noPan = false;

            controls.staticMoving = true;
            controls.dynamicDampingFactor = 0.3;

            controls.keys = new int[] { 65, 83, 68 };
        }
コード例 #9
0
ファイル: demo_shadow.cs プロジェクト: zonneryx/SharpThreejs
        public override void Init()
        {
            // create a scene, that will hold all our elements such as objects, cameras and lights.
            scene = new THREE.Scene();

            // create a camera, which defines where we're looking at.
            camera = new THREE.PerspectiveCamera(45, Width / Height, 0.1, 1000);

            // create a render and set the size
            renderer = new THREE.WebGLRenderer();

            renderer.setClearColor(new THREE.Color(0xEEEEEE));
            renderer.setSize(Width, Height);
            renderer.shadowMapEnabled = true;
            // add the output of the renderer to the html element
            Container.AppendChild(renderer.domElement);


            // create the ground plane
            var planeGeometry = new THREE.PlaneGeometry(60, 20);
            var planeMaterial = new THREE.MeshLambertMaterial();

            planeMaterial.color = new THREE.Color(0.9, 0.9, 0.9);
            var plane = new THREE.Mesh(planeGeometry, planeMaterial);

            plane.receiveShadow = true;

            // rotate and position the plane
            plane.rotation.x = -0.5 * Math.PI;
            plane.position.x = 15;
            plane.position.y = 0;
            plane.position.z = 0;

            // add the plane to the scene
            scene.add(plane);

            // create a cube
            var cubeGeometry = new THREE.CubeGeometry(4, 4, 4);
            var cubeMaterial = new THREE.MeshLambertMaterial(); // { color = 0xff0000 };

            cubeMaterial.color = new THREE.Color(1, 0, 0);
            var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);

            cube.castShadow = true;

            // position the cube
            cube.position.x = -4;
            cube.position.y = 3;
            cube.position.z = 0;

            // add the cube to the scene
            scene.add(cube);

            var sphereGeometry = new THREE.SphereGeometry(4, 20, 20);
            var sphereMaterial = new THREE.MeshLambertMaterial(); // { color = 0x7777ff };

            sphereMaterial.color = new THREE.Color(0, 0, 1);
            var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);

            // position the sphere
            sphere.position.x = 20;
            sphere.position.y = 4;
            sphere.position.z = 2;
            sphere.castShadow = true;

            // add the sphere to the scene
            scene.add(sphere);

            // position and point the camera to the center of the scene
            camera.position.x = -30;
            camera.position.y = 40;
            camera.position.z = 30;
            camera.lookAt(scene.position);

            // add spotlight for the shadows
            var spotLight = new THREE.SpotLight(); //0xffffff);

            spotLight.color = new THREE.Color(1, 1, 1);
            spotLight.position.set(-40, 60, -10);
            spotLight.castShadow = true;
            scene.add(spotLight);



            controls = new THREE.TrackballControls(camera);

            controls.rotateSpeed = 10.0;
            controls.zoomSpeed   = 1.2;
            controls.panSpeed    = 0.8;

            controls.noZoom = false;
            controls.noPan  = false;

            controls.staticMoving         = true;
            controls.dynamicDampingFactor = 0.3;

            controls.keys = new int[] { 65, 83, 68 };
        }