main
wangqiujuan0808 2023-12-01 20:34:18 +08:00
commit 7067612e02
9 changed files with 125 additions and 29 deletions

View File

@ -27,6 +27,7 @@
"jsencrypt": "3.3.1", "jsencrypt": "3.3.1",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"pinia": "2.0.22", "pinia": "2.0.22",
"three": "^0.148.0",
"vue": "3.2.45", "vue": "3.2.45",
"vue-cropper": "1.0.3", "vue-cropper": "1.0.3",
"vue-router": "4.1.4", "vue-router": "4.1.4",
@ -37,9 +38,9 @@
"@vue/compiler-sfc": "3.2.45", "@vue/compiler-sfc": "3.2.45",
"sass": "1.56.1", "sass": "1.56.1",
"unplugin-auto-import": "0.11.4", "unplugin-auto-import": "0.11.4",
"unplugin-vue-setup-extend-plus": "0.4.9",
"vite": "3.2.3", "vite": "3.2.3",
"vite-plugin-compression": "0.5.1", "vite-plugin-compression": "0.5.1",
"vite-plugin-svg-icons": "2.0.1", "vite-plugin-svg-icons": "2.0.1"
"unplugin-vue-setup-extend-plus": "0.4.9"
} }
} }

BIN
public/jz/glb/Floor.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
public/jz/glb/glass1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
public/jz/glb/jz.bin Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 MiB

1
public/jz/glb/jz.gltf Normal file

File diff suppressed because one or more lines are too long

BIN
public/jz/glb/柱子.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -0,0 +1,41 @@
<template>
<div class="app-container">
<div id="qmviewer_container">
<qmviewer
v-bind:modelName="modelName"
v-bind:isCompont="isCompont"
@callFather_loaded="callFather_loaded"
></qmviewer>
</div>
</div>
</template>
<script setup name="bimHome">
import Qmviewer from "@/components/Qmviewer";
const data = reactive({
viewerDemo: null,
isLocal: true, // true
//
modelName: "static/gltf/01/revit2018-1.gltf", //
// modelName: "static/gltf/bw/jz.gltf",
isCompont: true,
qmodel_container: null,
});
const { isLocal, modelName, isCompont, viewerDemo } = toRefs(data);
const callFather_loaded = (parm) => {
viewerDemo.value = parm;
console.log("组件Demo", viewerDemo.value);
//
qmodel.set_select_callback(function (id) {
var cmps = JSON.parse(id);
console.log(cmps);
});
};
</script>
<style lang='scss' scoped>
#qmviewer_container {
height: 900px;
background: #f8f8f9;
}
</style>

View File

@ -1,41 +1,94 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div id="qmviewer_container"> <canvas id="three"></canvas>
<qmviewer
v-bind:modelName="modelName"
v-bind:isCompont="isCompont"
@callFather_loaded="callFather_loaded"
></qmviewer>
</div>
</div> </div>
</template> </template>
<script setup name="bimHome"> <script setup name="bimHome">
import Qmviewer from "@/components/Qmviewer"; import * as THREE from "three";
const data = reactive({ import { ref, onMounted } from "vue";
viewerDemo: null, import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
isLocal: true, // true // :
// import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
modelName: "static/gltf/01/revit2018-1.gltf", // import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";
// modelName: "static/gltf/bw/jz.gltf", import {
isCompont: true, CSS2DObject,
qmodel_container: null, CSS2DRenderer,
} from "three/examples/jsm/renderers/CSS2DRenderer";
let scene = ref(null);
let renderer = ref(null);
let camera = ref(null);
let orbit = ref(null);
let group = ref(null);
let mouse = new THREE.Vector2();
let raycaster = new THREE.Raycaster();
let labelRenderer = new CSS2DRenderer(); //CSS2DRenderer
onMounted(() => {
init();
loadSence();
//
renderScene();
}); });
const init = () => {
scene = new THREE.Scene();
scene.background = new THREE.Color("#eee");
const canvas = document.querySelector("#three");
var cubeLoader = new THREE.CubeTextureLoader();
// WebGLRenderer使
renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
camera = new THREE.PerspectiveCamera(
55,
window.innerWidth / window.innerHeight,
0.1,
20000
);
//
camera.position.x = 100;
camera.position.y = 80;
camera.position.z = -150;
camera.lookAt(scene.position);
//
orbit = new OrbitControls(camera, renderer.domElement);
orbit.autoRotate = true;
setTimeout(function () {
orbit.autoRotate = false;
}, 7000);
renderer.setClearColor(new THREE.Color("#0e0934"));
renderer.setSize(window.innerWidth, window.innerHeight);
// 0x4444440x888888,threejs
// intensity 0.5
var alight = new THREE.AmbientLight(0xffffff, 0.5);
alight.name = "aLight";
scene.add(alight);
};
const { isLocal, modelName, isCompont, viewerDemo } = toRefs(data); const loadSence = () => {
const gltfLoader = new GLTFLoader();
const callFather_loaded = (parm) => { gltfLoader.load("/jz/glb/jz.gltf", (gltf) => {
viewerDemo.value = parm; console.log(1, gltf);
console.log("组件Demo", viewerDemo.value); var model = gltf.scene;
// scene.add(model);
qmodel.set_select_callback(function (id) { // emssivematerial.coloremissiveMapmaterial.map
var cmps = JSON.parse(id); // gltf.scene.traverse(function (child) {
console.log(cmps); // if (child.isMesh) {
// child.material.emissive = child.material.color;
// child.material.emissiveMap = child.material.map;
// }
// });
}); });
}; };
const renderScene = () => {
orbit.update(); //
// 使requestAnimationFrame
requestAnimationFrame(renderScene);
renderer.render(scene, camera);
// requestAnimationFrame,
labelRenderer.render(scene, camera);
};
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
#qmviewer_container { #three {
height: 900px; height: 900px;
background: #f8f8f9; width: 100%;
} }
</style> </style>