main
			
			
		
		
							parent
							
								
									cd8fe06628
								
							
						
					
					
						commit
						0271ed9129
					
				
							
								
								
									
										381470
									
								
								public/jzc/scene.gltf
								
								
								
								
							
							
						
						
									
										381470
									
								
								public/jzc/scene.gltf
								
								
								
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script setup>
 | 
			
		||||
import { onMounted, ref,watch } from 'vue';
 | 
			
		||||
import { onMounted, ref, watch } from 'vue';
 | 
			
		||||
import * as THREE from 'three';
 | 
			
		||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
 | 
			
		||||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +39,12 @@ onMounted(() => {
 | 
			
		|||
    renderScene();
 | 
			
		||||
    //点击模型
 | 
			
		||||
    document.addEventListener('click', onMouseDown);
 | 
			
		||||
    // 右击事件
 | 
			
		||||
    window.addEventListener('contextmenu', function (e) {
 | 
			
		||||
        if (e.button === 2) {
 | 
			
		||||
            console.log("点击了鼠标右键");
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    // document.addEventListener("mousemove", onMouseMove);
 | 
			
		||||
});
 | 
			
		||||
let scene, renderer, camera, controls, pointsArr = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +56,7 @@ const data = reactive({
 | 
			
		|||
    isAddLabel: true,
 | 
			
		||||
    isRemoveBottom: true
 | 
			
		||||
});
 | 
			
		||||
const { isAddLabel,isRemoveBottom } = toRefs(data);
 | 
			
		||||
const { isAddLabel, isRemoveBottom } = toRefs(data);
 | 
			
		||||
// 建筑树点击
 | 
			
		||||
Bus.on('clickBuild', (isParent) => {
 | 
			
		||||
    // Todo
 | 
			
		||||
| 
						 | 
				
			
			@ -92,15 +98,15 @@ watch(() => bimStore().activateMenu, value => {
 | 
			
		|||
    // 更换场景颜色
 | 
			
		||||
    scene.background = new THREE.Color(value.background);
 | 
			
		||||
    toHomeView();
 | 
			
		||||
},{ deep: true });
 | 
			
		||||
}, { deep: true });
 | 
			
		||||
 | 
			
		||||
const init = () => {
 | 
			
		||||
    // 场景
 | 
			
		||||
    scene = new THREE.Scene();
 | 
			
		||||
    scene.background = new THREE.Color(bimStore().activateMenu.background);
 | 
			
		||||
    // 相机
 | 
			
		||||
    camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000); 
 | 
			
		||||
    camera.position.set(-92.650, 67.456, 38.088); 
 | 
			
		||||
    camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
 | 
			
		||||
    camera.position.set(-92.650, 67.456, 38.088);
 | 
			
		||||
    //渲染器
 | 
			
		||||
    renderer = new THREE.WebGLRenderer({ antialias: true });
 | 
			
		||||
    renderer.setPixelRatio(window.devicePixelRatio);
 | 
			
		||||
| 
						 | 
				
			
			@ -117,9 +123,9 @@ const loadSence = () => {
 | 
			
		|||
    const dracoLoader = new DRACOLoader();
 | 
			
		||||
    dracoLoader.setDecoderPath('/draco/gltf/')//设置解压库文件路径
 | 
			
		||||
    gltfLoader.setDRACOLoader(dracoLoader)
 | 
			
		||||
    gltfLoader.load('/jzc/scene3.gltf', (gltf) => {
 | 
			
		||||
        var model = gltf.scene; 
 | 
			
		||||
        roamdObjects = model.children[0].children; 
 | 
			
		||||
    gltfLoader.load('/jzc/scene.gltf', (gltf) => {
 | 
			
		||||
        var model = gltf.scene;
 | 
			
		||||
        roamdObjects = model.children[0].children;
 | 
			
		||||
        scene.add(model);
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -386,9 +392,9 @@ const removeLabel = () => {
 | 
			
		|||
 | 
			
		||||
// 设置地板
 | 
			
		||||
const setBottom = () => {
 | 
			
		||||
    var target = scene.getObjectByName('set1');
 | 
			
		||||
    var target = scene.getObjectByName('floor2F');
 | 
			
		||||
    console.log(target);
 | 
			
		||||
    if (isRemoveBottom.value) {
 | 
			
		||||
        var target = scene.getObjectByName('set1');
 | 
			
		||||
        target.visible = false;
 | 
			
		||||
    } else {
 | 
			
		||||
        target.visible = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue