From ebf2ca66bd8d6324080d52298b7a737483110062 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期二, 28 十二月 2021 10:42:46 +0800
Subject: [PATCH] #

---
 static/js/app.js                |   83 +++++--------
 /dev/null                       |  216 ------------------------------------
 static/js/object/StoreConvey.js |    5 
 static/js/object/StoreCrn.js    |   41 +-----
 4 files changed, 42 insertions(+), 303 deletions(-)

diff --git a/static/js/app.js b/static/js/app.js
index 7b05551..65fe1ba 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -30,7 +30,7 @@
 		this.direction = new THREE.Vector3();
 		this.raycaster = null;
 		this.prevTime = performance.now();//涓婁竴娆ender鐨勬椂闂�
-		this.backgroundType = true;
+		this.backgroundType = false;
 
 		this.start = function () {
 			this.initMain();
@@ -65,20 +65,7 @@
 		}
 		this.initCamera = function () {
 			if (this.camera === null) {
-				//澹版槑涓�涓�忚鐩告満锛�
-				// 瑙嗚锛�60锛�
-				// 绾垫í姣攁spect:鍏ㄥ睆锛屼娇鐢ㄧ殑鏄祻瑙堝櫒鐨勫搴�/楂樺害
-				//杩戝钩闈ear锛�0.1
-				//杩滃钩闈㈣瑙抐ar:10000
 				this.camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 50000);
-				/*
-                璁剧疆鐩告満浣嶇疆锛屾敞鎰弔hreejs涓殑鍧愭爣绯婚噰鐢ㄧ殑鏄彸鎵嬪潗鏍囩郴
-                 */
-				// this.camera.position.x = 0;
-				// this.camera.position.y = 1000;
-				// this.camera.position.z = 600;
-				// //鐩告満鐨勬湞鍚�
-				// this.camera.lookAt(0, 0, 0);
 				this.camera.position.set( -350, 600, 1100 );
 				this.camera.lookAt( this.scene.position );
 				//灏嗙浉鏈烘斁鍒板満鏅腑
@@ -91,54 +78,46 @@
 		this.initRenderer = function () {
 			this.renderer = new THREE.WebGLRenderer();
 
-			// this.renderer.outputEncoding = THREE.sRGBEncoding;
-			// this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
-			// this.renderer.toneMappingExposure = 0.5;
-
-			// this.renderer.outputEncoding = THREE.sRGBEncoding;
-			// this.renderer.shadowMap.enabled = true;
-			// this.renderer.toneMapping = THREE.ReinhardToneMapping;
-			//
+			this.renderer = new THREE.WebGLRenderer({
+				antialias: true,
+				logarithmicDepthBuffer: true
+			});
+			this.renderer.setSize(window.innerWidth, window.innerHeight);
 			this.renderer.setPixelRatio( window.devicePixelRatio );
-			this.renderer.setSize( window.innerWidth, window.innerHeight );
+			this.renderer.shadowMap.enabled = true;
+			this.renderer.shadowMap.type = THREE.BasicShadowMap;
 			this.dom = document.getElementById("container");
-			this.dom.appendChild( this.renderer.domElement );
-
+			this.dom.appendChild(this.renderer.domElement);
 
 		}
 		this.initLight = function () {
-
 			//棣栧厛娣诲姞涓幆澧冨厜
 			let ambient = new THREE.AmbientLight(0xffffff, 1); //AmbientLight,褰卞搷鏁翠釜鍦烘櫙鐨勫厜婧�
 			ambient.position.set(0, 0, 0);
 			this.addObject(ambient);
-			//娣诲姞骞宠鍏�,骞宠鍏夌被浼间簬澶槼鍏�
-			let directionalLight = new THREE.DirectionalLight(0xffffff, 0.3);//妯℃嫙杩滃绫讳技澶槼鐨勫厜婧�
-			directionalLight.position.set(0, 200, 0);
-			this.addObject(directionalLight);
-			//璁剧疆鐐瑰厜婧�
-			let pointLight1 = new THREE.PointLight(0xffffff, 0.3);
-			pointLight1.position.set(-500, 200, 0);
-			this.addObject(pointLight1);
-			let pointLight2 = new THREE.PointLight(0xffffff, 0.3);
-			pointLight2.position.set(500, 200, 0);
-			this.addObject(pointLight2);
 
-			// const bulbGeometry = new THREE.SphereGeometry( 0.02, 16, 8 );
-			// var bulbLight = new THREE.PointLight( 0xffee88, 1, 100, 2 );
-			//
-			// var bulbMat = new THREE.MeshStandardMaterial( {
-			// 	emissive: 0xffffee,
-			// 	emissiveIntensity: 1,
-			// 	color: 0x000000
-			// } );
-			// bulbLight.add( new THREE.Mesh( bulbGeometry, bulbMat ) );
-			// bulbLight.position.set( -500, 22, 0 );
-			// bulbLight.castShadow = true;
-			// this.addObject( bulbLight );
-			//
-			// var hemiLight = new THREE.HemisphereLight( 0xddeeff, 0x0f0e0d, 0.02 );
-			// this.addObject( hemiLight );
+			// 娣诲姞骞宠鍏�,骞宠鍏夌被浼间簬澶槼鍏�
+			// let directionalLight = new THREE.DirectionalLight(0xffffff, 0.3);//妯℃嫙杩滃绫讳技澶槼鐨勫厜婧�
+			// directionalLight.position.set(0, 200, 0);
+			// this.addObject(directionalLight);
+			// //璁剧疆鐐瑰厜婧�
+			// let pointLight1 = new THREE.PointLight(0xffffff, 0.3);
+			// pointLight1.position.set(-500, 200, 0);
+			// this.addObject(pointLight1);
+			// let pointLight2 = new THREE.PointLight(0xffffff, 0.3);
+			// pointLight2.position.set(500, 200, 0);
+			// this.addObject(pointLight2);
+
+			// 闃村奖鑱氬厜鐏�
+			let pointLight = new THREE.SpotLight(0xFFFAFA,1);
+			pointLight.position.set(0, 1500, 2500);
+			pointLight.castShadow = true;
+			pointLight.shadow.camera.near = 2000;
+			pointLight.shadow.camera.far = 10000;
+			pointLight.shadow.mapSize.height = 100000;
+			pointLight.shadow.mapSize.width = 100000;
+			// 灏嗘墍鏈夊垱寤虹殑鐗╀綋鍔犲叆鍒板満鏅腑鍘�
+			this.addObject(pointLight);
 		}
 		this.initOrbitControl = function () {
 			this.orbitControl = new OrbitControls(this.camera, this.renderer.domElement);
diff --git a/static/js/object/StoreConvey.js b/static/js/object/StoreConvey.js
index 02418e9..a601f80 100644
--- a/static/js/object/StoreConvey.js
+++ b/static/js/object/StoreConvey.js
@@ -46,8 +46,11 @@
                             color: 0x000000
                         });
                     }
+                    child.castShadow = true;
+                    child.receiveShadow = true;
                 }
             });
+
             chainList.map(item => {
                 that.object.addObject(customize(obj.clone(), item));
             })
@@ -59,6 +62,8 @@
                     child.material = new THREE.MeshLambertMaterial({
                         color: 0x444444
                     });
+                    child.castShadow = true;
+                    child.receiveShadow = true;
                 }
             });
             rollerList.map(item => {
diff --git a/static/js/object/StoreConvey0.js b/static/js/object/StoreConvey0.js
deleted file mode 100644
index a6be8d8..0000000
--- a/static/js/object/StoreConvey0.js
+++ /dev/null
@@ -1,216 +0,0 @@
-import {MTLLoader} from "../lib/MTLLoader.js";
-import {OBJLoader} from "../lib/OBJLoader.js";
-import * as THREE from '../three.module.js';
-
-const xOffset = 35;
-const yOffset = 44;
-const zOffset = 28;
-
-const xOffset0 = -1407;
-const yOffset0 = 0;
-const zOffset0 = 490;
-
-function StoreConvey(object) {
-
-    // transport
-
-    // roller
-
-    const manager = new THREE.LoadingManager();
-
-    let chain = null;
-    new MTLLoader(manager)
-        .setPath( '../static/model/obj/' )
-        .load( '閾炬潯杈撻�佹満.mtl', function ( materials ) {
-            materials.preload();
-            new OBJLoader( manager )
-                .setMaterials( materials )
-                .setPath( '../static/model/obj/' )
-                .load( '閾炬潯杈撻�佹満.obj', function ( obj ) {
-                    chain = obj;
-                    chain.scale.set(0.03, 0.03, 0.025);
-                    chain.rotateY( -Math.PI / 2);
-                    chain.traverse (function (child) {
-                        if (child instanceof THREE.Mesh) {
-                            child.material = new THREE.MeshLambertMaterial({
-                                color: 0xAAAAAA
-                            });
-                        }
-                    });
-
-                    for (let i = 0; i<24; i++) {
-                        let clone = chain.clone();
-                        // roller.name = option.crnNo + "-body";
-                        let offset = 0;
-                        if (i % 2 === 0) {
-                            offset = 90;
-                        }
-                        clone.position.x = xOffset0 + 56 + offset + Math.floor(i/2)*230;
-                        clone.position.y = yOffset0;
-                        clone.position.z = zOffset0 + 39;
-                        object.addObject( clone );
-                    }
-
-                    for (let i = 0; i<24; i++) {
-                        let clone = chain.clone();
-                        // roller.name = option.crnNo + "-body";
-                        let offset = 0;
-                        if (i % 2 === 0) {
-                            offset = 90;
-                        }
-                        clone.position.x = xOffset0 + 56 + offset + Math.floor(i/2)*230;
-                        clone.position.y = yOffset0;
-                        clone.position.z = zOffset0 + 39 + 82;
-                        object.addObject( clone );
-                    }
-
-                    for (let i = 0; i<24; i++) {
-                        var clone = chain.clone();
-                        // roller.name = option.crnNo + "-body";
-                        let offset = 0;
-                        if (i % 2 === 0) {
-                            offset = 90;
-                        }
-                        clone.position.x = xOffset0 + 56 + offset + Math.floor(i/2)*230;
-                        clone.position.y = yOffset0 + 310;
-                        clone.position.z = zOffset0 + 39;
-                        object.addObject( clone );
-                    }
-
-                }, null, null );
-        });
-
-    let roller = null;
-    new MTLLoader(manager)
-    	.setPath( '../static/model/obj/' )
-    	.load( '123.mtl', function ( materials ) {
-    		materials.preload();
-    		new OBJLoader( manager )
-    			.setMaterials( materials )
-    			.setPath( '../static/model/obj/' )
-    			.load( '123.obj', function ( obj ) {
-                    roller = obj;
-                    roller.traverse (function (child) {
-                        if (child instanceof THREE.Mesh) {
-                            child.material = new THREE.MeshLambertMaterial({
-                                color: 0xAAAAAA
-                            });
-                        }
-                    });
-
-                    roller.scale.set(55, 45, 55);
-                    // roller.rotateY(- Math.PI / 2);
-                    // roller.name = option.crnNo + "-body";
-                    roller.position.x = xOffset + 60;
-                    roller.position.y = yOffset;
-                    roller.position.z = zOffset + 140;
-                    // object.addObject( roller );
-
-    			}, null, null );
-    });
-
-    new THREE.ObjectLoader().load( "../static/model/json/椤跺崌绉绘牻.json", function (obj) {
-        obj.traverse (function (child) {
-            if (child instanceof THREE.Mesh) {
-                child.scale.set(1, 1, 1.8);
-                child.material = new THREE.MeshLambertMaterial({
-                    color: 0xAAAAAA
-                });
-            }
-        });
-        obj.position.x = 20;
-        obj.position.y = 0;
-        obj.position.z = -30;
-        object.addObject( obj );
-    } );
-    new THREE.ObjectLoader().load( "../static/model/json/閾炬潯杈撻�佹満.json", function (obj) {
-        obj.traverse (function (child) {
-            if (child instanceof THREE.Mesh) {
-                child.scale.set(1, 1, 1);
-                child.material = new THREE.MeshLambertMaterial({
-                    color: 0xAAAAAA
-                });
-            }
-        });
-        obj.position.x = 0;
-        obj.position.y = 0;
-        obj.position.z = 0;
-        object.addObject( obj );
-    } );
-    new THREE.ObjectLoader().load( "../static/model/json/杈婄瓛杈撻�佹満.json", function (obj) {
-        obj.traverse (function (child) {
-            if (child instanceof THREE.Mesh) {
-                child.scale.set(1, 1, 1);
-                child.material = new THREE.MeshLambertMaterial({
-                    color: 0xAAAAAA
-                });
-            }
-        });
-        obj.position.x = 0;
-        obj.position.y = 0;
-        obj.position.z = 0;
-        object.addObject( obj );
-    } );
-
-
-    // new MTLLoader(manager)
-    //     .setPath( '../static/model/obj/' )
-    //     .load( '绉绘牻杈撻�佹満.mtl', function ( materials ) {
-    //         materials.preload();
-    //         new OBJLoader( manager )
-    //             .setMaterials( materials )
-    //             .setPath( '../static/model/obj/' )
-    //             .load( '绉绘牻杈撻�佹満.obj', function ( obj ) {
-    //
-    //                 obj.scale.set(1000, 1000, 1000);
-    //                 // roller.rotateY(- Math.PI / 2);
-    //                 // roller.name = option.crnNo + "-body";
-    //                 obj.position.x = 0;
-    //                 obj.position.y = 0;
-    //                 obj.position.z = 0;
-    //                 object.addObject( obj );
-    //
-    //             }, null, null );
-    //     });
-
-
-    // new OBJLoader().load(
-    //     '../static/model/obj/model (8).obj',
-    //     function ( group ) {
-    //         const cerberus = group.children[ 0 ];
-    //         const modelGeometry = cerberus.geometry;
-    //
-    //         let shelfMat = new THREE.MeshPhysicalMaterial({
-    //             color: 0x175EC0,
-    //             transparent: true,
-    //             opacity: 1
-    //         });
-    //
-    //         let mesh = new THREE.Mesh( modelGeometry, shelfMat );
-    //         mesh.scale.set(1, 1, 1)
-    //         mesh.position.x = 0;
-    //         mesh.position.y = 0;
-    //         mesh.position.z = 0;
-    //         // object.addObject( mesh );
-    //
-    //     });
-
-    // new THREE.BufferGeometryLoader().load( '../static/model/json/suzanne_buffergeometry.json', function ( geometry ) {
-    //     console.log(geometry)
-    //     let shelfMat = new THREE.MeshPhysicalMaterial({
-    //         color: 0x175EC0,
-    //         transparent: true,
-    //         opacity: 1
-    //     });
-    //     let mesh = new THREE.Mesh( geometry, shelfMat );
-    //     mesh.scale.set(1, 1, 1)
-    //     mesh.position.x = 0;
-    //     mesh.position.y = 0;
-    //     mesh.position.z = 0;
-    //     object.addObject( mesh );
-    // })
-
-
-}
-
-export {StoreConvey}
diff --git a/static/js/object/StoreCrn.js b/static/js/object/StoreCrn.js
index 17c4c22..cb0c408 100644
--- a/static/js/object/StoreCrn.js
+++ b/static/js/object/StoreCrn.js
@@ -26,41 +26,6 @@
     this.crnForkWidth = option.crnFork.width||20;//搴撲綅瀹�
     this.crnForkHeight = option.crnFork.height||30;//搴撲綅楂�
 
-    // 绔嬫煴
-    // var a = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnBodyLength, this.crnBodyHeight, this.crnBodyWidth), new THREE.MeshBasicMaterial({
-    //     color: 0xff0000,
-    //     transparent: true,
-    //     opacity: .3
-    // }))
-    // a.name = option.crnNo + "-body";
-    // a.position.x = option.crnBody.position.x;
-    // a.position.y = option.crnBody.position.y + this.crnBodyHeight/2;
-    // a.position.z = option.crnBody.position.z - this.crnBodyWidth/2;
-    // object.addObject(a);
-    // 杞借揣鍙�
-    // var b = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnLoadLength, this.crnLoadHeight, this.crnLoadWidth), new THREE.MeshBasicMaterial({
-    //     color: 0x00ff00,
-    //     transparent: true,
-    //     opacity: .5
-    // }))
-    // b.name = option.crnNo + "-load";
-    // b.position.x = option.crnLoad.position.x;
-    // b.position.y = option.crnLoad.position.y + this.crnLoadHeight/2;
-    // b.position.z = option.crnLoad.position.z - this.crnLoadWidth/2 + 5;
-    // object.addObject(b);
-    // 鍙夌墮
-    // var c = new THREE.Mesh(new THREE.BoxBufferGeometry(this.crnForkLength, this.crnForkWidth, this.crnForkHeight), new THREE.MeshBasicMaterial({
-    //     color: 0xff00ff,
-    //     transparent: true,
-    //     opacity: 1
-    // }))
-    // c.name = option.crnNo + "-fork";
-    // c.position.x = option.crnFork.position.x;
-    // c.position.y = option.crnFork.position.y + this.crnLoadHeight/2;
-    // c.position.z = option.crnFork.position.z - this.crnLoadWidth/2;
-    // object.addObject(c);
-
-
     const manager = new THREE.LoadingManager();
     new MTLLoader(manager)
         .setPath( '../static/model/obj/' )
@@ -71,6 +36,8 @@
                 .setPath( '../static/model/obj/' )
                 .load( '鍫嗗灈鏈烘湰浣�.obj', function ( obj ) {
                     obj.traverse (function (child) {
+                        child.castShadow = true;
+                        child.receiveShadow = true;
                         if (child instanceof THREE.Mesh) {
                             child.material = new THREE.MeshLambertMaterial({
                                 color: 0xCD6839
@@ -97,6 +64,8 @@
                 .load( '杞借揣鍙�.obj', function ( obj ) {
                     obj.traverse (function (child) {
                         if (child instanceof THREE.Mesh) {
+                            child.castShadow = true;
+                            child.receiveShadow = true;
                             child.material = new THREE.MeshLambertMaterial({
                                 color: 0xD2691E
                             });
@@ -122,6 +91,8 @@
                 .load( '璐у弶.obj', function ( obj ) {
                     obj.traverse (function (child) {
                         if (child instanceof THREE.Mesh) {
+                            child.castShadow = true;
+                            child.receiveShadow = true;
                             child.material = new THREE.MeshLambertMaterial({
                                 color: 0x363636
                             });

--
Gitblit v1.9.1