wangqiujuan0808 2023-12-15 09:48:43 +08:00
parent 1be51561e1
commit 5a86c02286
3 changed files with 19 additions and 64 deletions

BIN
public/jzc.7z Normal file

Binary file not shown.

View File

@ -99,10 +99,8 @@ const init = () => {
scene = new THREE.Scene(); scene = new THREE.Scene();
scene.background = new THREE.Color(bimStore().activateMenu.background); scene.background = new THREE.Color(bimStore().activateMenu.background);
// //
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000); camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
// camera.position.z = 5; camera.position.set(-92.650, 67.456, 38.088);
camera.position.set(-92.650, 67.456, 38.088);
// camera.position.set(-92.936, 180.990, -28.179);
// //
renderer = new THREE.WebGLRenderer({ antialias: true }); renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio); renderer.setPixelRatio(window.devicePixelRatio);
@ -120,10 +118,8 @@ const loadSence = () => {
dracoLoader.setDecoderPath('/draco/gltf/')// dracoLoader.setDecoderPath('/draco/gltf/')//
gltfLoader.setDRACOLoader(dracoLoader) gltfLoader.setDRACOLoader(dracoLoader)
gltfLoader.load('/jzc/scene3.gltf', (gltf) => { gltfLoader.load('/jzc/scene3.gltf', (gltf) => {
var model = gltf.scene; var model = gltf.scene;
// console.log(roamdObjects); roamdObjects = model.children[0].children;
roamdObjects = model.children[0].children;
// console.log(model.children[0].children);
scene.add(model); scene.add(model);
}); });
}; };
@ -133,12 +129,6 @@ const renderScene = () => {
controls.update(); controls.update();
renderer.render(scene, camera); renderer.render(scene, camera);
labelRenderer.render(scene, camera); labelRenderer.render(scene, camera);
// if (roamdObjects.length > 0) {
// const currentModel = roamdObjects.shift();
// setTimeout(() => {
// roam(currentModel);
// }, 3000);
// }
}; };
const onWindowResize = () => { const onWindowResize = () => {
@ -203,36 +193,20 @@ const onMouseMove = (event) => {
} }
// //
const onMouseDown = (event) => { const onMouseDown = (event) => {
var vector = new THREE.Vector3();// var raycaster = new THREE.Raycaster()
vector.set( mouse.x = ((event.clientX - marginLeft) / window.innerWidth) * 2 - 1;
(event.clientX / window.innerWidth) * 2 - 1, mouse.y = -((event.clientY - marginTop) / window.innerHeight) * 2 + 1;
- (event.clientY / window.innerHeight) * 2 + 1, raycaster.setFromCamera(mouse, camera);
0.5); const intersects = raycaster.intersectObjects(scene.children, true);
vector.unproject(camera); console.log(123, event);
var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());
var intersects = raycaster.intersectObjects(scene.children);
if (intersects.length > 0) { if (intersects.length > 0) {
var selected = intersects[0];// const clickedObject = intersects[0].object;
console.log("x坐标:" + selected.point.x); console.log('这是我选中的模型', clickedObject);
console.log("y坐标:" + selected.point.y); var selectedObject = isSelent(clickedObject);
console.log("z坐标:" + selected.point.z); //
boxLight(selectedObject);
} }
// var raycaster = new THREE.Raycaster()
// mouse.x = ((event.clientX - marginLeft) / window.innerWidth) * 2 - 1;
// mouse.y = -((event.clientY - marginTop) / window.innerHeight) * 2 + 1;
// raycaster.setFromCamera(mouse, camera);
// const intersects = raycaster.intersectObjects(scene.children, true);
// console.log(123, event);
// if (intersects.length > 0) {
// const clickedObject = intersects[0].object;
// console.log('', clickedObject);
// var selectedObject = isSelent(clickedObject);
// //
// boxLight(selectedObject);
// }
} }
const boxLight = (selectedObject) => { const boxLight = (selectedObject) => {
@ -254,25 +228,6 @@ const centerSelectedGroup = (obj) => {
controls.enabled = true; controls.enabled = true;
}); });
tween.start(); tween.start();
// let distance = 100
// let angel = Math.PI / 5
// let position = {
// x: targetPosition.x + Math.sin(angel) * distance,
// // y: targetPosition.y,
// y: targetPosition.y + Math.sin(angel) * distance,
// z: targetPosition.z + Math.sin(angel) * distance,
// }
// let tween = new TWEEN.Tween(camera.position).to(position, 3000)
// let tween1 = new TWEEN.Tween(controls.target).to(targetPosition, 1000)
// // tween.start()
// tween1.start()
} }
// //
@ -300,7 +255,7 @@ const roam = () => {
renders(); renders();
}, 1000); }, 1000);
} }
function d(cameraCurve) { const d = (cameraCurve) => {
let sphereCurve = null; let sphereCurve = null;
//100 //100
//0.6 //0.6

View File

@ -38,8 +38,8 @@ const getCharts = () => {
}, },
grid: { grid: {
top: '24%', top: '24%',
left: '5%', left: '2%',
right: '8%', right: '2%',
// bottom: '2%', // bottom: '2%',
height: '80%', height: '80%',
containLabel: true containLabel: true