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.background = new THREE.Color(bimStore().activateMenu.background);
//
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.936, 180.990, -28.179);
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);
@ -120,10 +118,8 @@ const loadSence = () => {
dracoLoader.setDecoderPath('/draco/gltf/')//
gltfLoader.setDRACOLoader(dracoLoader)
gltfLoader.load('/jzc/scene3.gltf', (gltf) => {
var model = gltf.scene;
// console.log(roamdObjects);
roamdObjects = model.children[0].children;
// console.log(model.children[0].children);
var model = gltf.scene;
roamdObjects = model.children[0].children;
scene.add(model);
});
};
@ -133,12 +129,6 @@ const renderScene = () => {
controls.update();
renderer.render(scene, camera);
labelRenderer.render(scene, camera);
// if (roamdObjects.length > 0) {
// const currentModel = roamdObjects.shift();
// setTimeout(() => {
// roam(currentModel);
// }, 3000);
// }
};
const onWindowResize = () => {
@ -203,36 +193,20 @@ const onMouseMove = (event) => {
}
//
const onMouseDown = (event) => {
var vector = new THREE.Vector3();//
vector.set(
(event.clientX / window.innerWidth) * 2 - 1,
- (event.clientY / window.innerHeight) * 2 + 1,
0.5);
vector.unproject(camera);
var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());
var intersects = raycaster.intersectObjects(scene.children);
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) {
var selected = intersects[0];//
console.log("x坐标:" + selected.point.x);
console.log("y坐标:" + selected.point.y);
console.log("z坐标:" + selected.point.z);
const clickedObject = intersects[0].object;
console.log('这是我选中的模型', clickedObject);
var selectedObject = isSelent(clickedObject);
//
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) => {
@ -254,25 +228,6 @@ const centerSelectedGroup = (obj) => {
controls.enabled = true;
});
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();
}, 1000);
}
function d(cameraCurve) {
const d = (cameraCurve) => {
let sphereCurve = null;
//100
//0.6

View File

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