bx-1316-refactoring #14
Binary file not shown.
|
@ -6,6 +6,7 @@ import {
|
||||||
Vector2, Vector3,
|
Vector2, Vector3,
|
||||||
Object3D,
|
Object3D,
|
||||||
MeshPhongMaterial,
|
MeshPhongMaterial,
|
||||||
|
CircleGeometry,
|
||||||
} from 'three';
|
} from 'three';
|
||||||
|
|
||||||
import { useTresContext, useSeek, useTexture, useLoop } from '@tresjs/core';
|
import { useTresContext, useSeek, useTexture, useLoop } from '@tresjs/core';
|
||||||
|
@ -186,12 +187,13 @@ const loadModels = async () => {
|
||||||
|
|
||||||
const p = raw_data.min_distance * 0.05
|
const p = raw_data.min_distance * 0.05
|
||||||
|
|
||||||
const point = pointer_pin.clone()
|
const point = new Mesh(
|
||||||
|
new CircleGeometry(p, 32),
|
||||||
|
new MeshPhongMaterial({ emissive: new Color(1, 1, 1), emissiveIntensity: 10 })
|
||||||
|
)
|
||||||
point.rotateX(-0.5 * Math.PI)
|
point.rotateX(-0.5 * Math.PI)
|
||||||
point.position.set(world_position.x, p * 3, world_position.z * 2)
|
point.position.set(world_position.x, p * 3, world_position.z * 2)
|
||||||
point.name = `${element.id}_clickable`
|
point.name = `${element.id}_clickable`
|
||||||
point.scale.set(p * 2, p * 2, p * 2)
|
|
||||||
point.material = new MeshPhongMaterial({ emissive: new Color(1, 1, 1), emissiveIntensity: 10 })
|
|
||||||
point.updateMatrixWorld()
|
point.updateMatrixWorld()
|
||||||
|
|
||||||
if (clickable_items.value.find(el => el.name == point.name)) continue
|
if (clickable_items.value.find(el => el.name == point.name)) continue
|
||||||
|
@ -229,20 +231,11 @@ const loadModels = async () => {
|
||||||
(controls.value as any).autoRotate = false;
|
(controls.value as any).autoRotate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const lookAtCamera = (obj: Group) => {
|
|
||||||
if (!obj || !obj.children) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
obj.children.forEach((element: Object3D) => {
|
|
||||||
if (element && typeof element.lookAt == 'function' && camera.value) {
|
|
||||||
element.lookAt(obj.position.x, obj.position.y * Math.PI * -0.5, camera.value?.position.z)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const { onAfterRender } = useLoop()
|
const { onAfterRender } = useLoop()
|
||||||
onAfterRender(() => {
|
onAfterRender(() => {
|
||||||
clickable_refs.value.map(el => {
|
clickable_refs.value.map(el => {
|
||||||
lookAtCamera(el.value[0])
|
el.value[0].lookAt(camera.value?.position)
|
||||||
})
|
})
|
||||||
if (controls.value) {
|
if (controls.value) {
|
||||||
if (timer.value == 0) {
|
if (timer.value == 0) {
|
||||||
|
@ -254,24 +247,21 @@ onAfterRender(() => {
|
||||||
const openSidebar = (id: number) => {
|
const openSidebar = (id: number) => {
|
||||||
sidebar.open(id);
|
sidebar.open(id);
|
||||||
|
|
||||||
// const clickable = useClickable()
|
const clickable = useClickable()
|
||||||
// const target = clickable.list.find(el => el.id == id)
|
const target = clickable.list.find(el => el.id == id)
|
||||||
// if (!target) return
|
if (!target) return
|
||||||
// const el = seekByName(scene.value, target.object_name);
|
const el = seekByName(scene.value, `${id}_clickable`);
|
||||||
// if (el) {
|
console.log(el)
|
||||||
// // (controls.value as any).maxDistance = 10;
|
if (el) {
|
||||||
// // (controls.value as any).minDistance = 1;
|
(controls.value as any).maxDistance = 10;
|
||||||
// const target_vector = new Vector3();
|
(controls.value as any).minDistance = 1;
|
||||||
|
const target_vector = new Vector3();
|
||||||
|
|
||||||
// el.getWorldPosition(target_vector);
|
el.getWorldPosition(target_vector);
|
||||||
// (controls.value as any).target = target_vector;
|
(controls.value as any).target = target_vector;
|
||||||
// console.log(target_vector)
|
console.log(target_vector)
|
||||||
|
// (camera.value as any).lookAt(el)
|
||||||
// target_vector.copy( el.position );
|
}
|
||||||
// el.localToWorld( target_vector );
|
|
||||||
// console.log(target_vector)
|
|
||||||
// // (camera.value as any).lookAt(el)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadModels()
|
loadModels()
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
export const useRawData = defineStore('raw_data', {
|
||||||
|
state: () => {
|
||||||
|
return {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
Loading…
Reference in New Issue