#
luxiaotao1123
2021-11-26 a62854c555528aea050bbbc53273acbca7b483a7
#
1个文件已修改
149 ■■■■ 已修改文件
static/js/app.js 149 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/js/app.js
@@ -36,6 +36,7 @@
            this.renderer.render(this.scene, this.camera);
            this.stats.end();
            this.initStoreObjects(this);
            this.modelMove();
        }
        this.initScene = function () {
            this.scene = new THREE.Scene();
@@ -131,7 +132,7 @@
                "posy.jpg", "negy.jpg",
                "posz.jpg", "negz.jpg"
            ]);
            this.scene.background = new THREE.Color( 0xf0f0f0 );
            // this.scene.background = new THREE.Color( 0xf0f0f0 );
        }
        this.removeObject = function (nameorid) {
            for (let i = 0; i < this.objects.length; i++) {
@@ -161,78 +162,6 @@
            helper.material.opacity = 0.25;
            helper.material.transparent = true;
            this.addObject( helper );
        }
        this.initModel = function () {
            let that = this;
            // let object;
            // const onProgress = function ( xhr ) {
            //     if ( xhr.lengthComputable ) {
            //         const percentComplete = xhr.loaded / xhr.total * 100;
            //         console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
            //     }
            // };
            // const onError = function () { };
            // function loadModel() {
            //     object.traverse( function ( child ) {
            //         if ( child.isMesh ) child.material.map = texture;
            //     } );
            //     object.position.y = 195;
            //     that.addObject( object );
            // }
            // const manager = new THREE.LoadingManager(loadModel);
            // const textureLoader = new THREE.TextureLoader( manager );
            // const texture = textureLoader.load( '../static/model/obj/uv_grid_opengl.jpg' );
            // const loader = new OBJLoader( manager );
            // loader.load( '../static/model/obj/AGV.obj', function ( obj ) {
            //     object = obj;
            // }, onProgress, onError );
            const manager = new THREE.LoadingManager();
            // manager.addHandler( /\.dds$/i, new DDSLoader() );
            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 ( object ) {
                            object.position.z = -500;
                            object.position.x = -1560;
                            object.scale.set(0.025, 0.025, 0.025);
                            object.rotateY(- Math.PI / 2)
                            that.addObject( object );
                        }, null, 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 ( object ) {
                            object.position.z = -500;
                            object.position.x = -1560;
                            object.scale.set(0.025, 0.025, 0.025);
                            object.rotateY(- Math.PI / 2)
                            that.addObject( object );
                        }, null, 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 ( object ) {
                            object.position.z = -500;
                            object.position.x = -1560;
                            object.scale.set(0.025, 0.025, 0.025);
                            object.rotateY(- Math.PI / 2)
                            that.addObject( object );
                        }, null, null );
                });
        }
        this.initStoreObjects = function (object) {
            if (this.firstTime === 1) {
@@ -286,6 +215,80 @@
                }
            }
            return null;
        }
        this.initModel = function () {
            let that = this;
            // let object;
            // const onProgress = function ( xhr ) {
            //     if ( xhr.lengthComputable ) {
            //         const percentComplete = xhr.loaded / xhr.total * 100;
            //         console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
            //     }
            // };
            // const onError = function () { };
            // function loadModel() {
            //     object.traverse( function ( child ) {
            //         if ( child.isMesh ) child.material.map = texture;
            //     } );
            //     object.position.y = 195;
            //     that.addObject( object );
            // }
            // const manager = new THREE.LoadingManager(loadModel);
            // const textureLoader = new THREE.TextureLoader( manager );
            // const texture = textureLoader.load( '../static/model/obj/uv_grid_opengl.jpg' );
            // const loader = new OBJLoader( manager );
            // loader.load( '../static/model/obj/AGV.obj', function ( obj ) {
            //     object = obj;
            // }, onProgress, onError );
            const manager = new THREE.LoadingManager();
            // manager.addHandler( /\.dds$/i, new DDSLoader() );
            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 ( object ) {
                            object.position.z = -500;
                            object.position.x = -2060;
                            object.scale.set(0.025, 0.025, 0.025);
                            object.rotateY(- Math.PI / 2)
                            that.addObject( object );
                        }, null, 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 ( object ) {
                            object.position.z = -500;
                            object.position.x = -2060;
                            object.scale.set(0.025, 0.025, 0.025);
                            object.rotateY(- Math.PI / 2)
                            that.addObject( object );
                        }, null, 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 ( object ) {
                            object.position.z = -500;
                            object.position.x = -2060;
                            object.scale.set(0.025, 0.025, 0.025);
                            object.rotateY(- Math.PI / 2)
                            that.addObject( object );
                        }, null, null );
                });
        }
        this.modelMove = function () {
        }
    },