bx-1316-refactoring #14
|
@ -3,7 +3,8 @@ import { onMounted, onUnmounted, reactive, ref, watch } from 'vue';
|
|||
import {
|
||||
Box3, Color, DoubleSide, Group, Mesh, PlaneGeometry,
|
||||
MeshStandardMaterial, MeshStandardMaterialParameters,
|
||||
Vector2, Vector3
|
||||
Vector2, Vector3,
|
||||
Object3D
|
||||
} from 'three';
|
||||
|
||||
import { useTresContext, useSeek, useTexture, useLoop } from '@tresjs/core';
|
||||
|
@ -210,20 +211,11 @@ const loadModels = async () => {
|
|||
|
||||
const { onAfterRender } = useLoop()
|
||||
onAfterRender(() => {
|
||||
let i = 0.01
|
||||
clickable_refs.value.map(el => {
|
||||
// i += 2
|
||||
if (el.value[0].children[0] && typeof el.value[0].children[0].lookAt == 'function') {
|
||||
if (el.value[0] && el.value[0].children[0] && typeof el.value[0].children[0].lookAt == 'function') {
|
||||
el.value[0].children[0].lookAt(camera.value?.position);
|
||||
el.value[0].children[1].lookAt(camera.value?.position);
|
||||
}
|
||||
if (el.value[0].children[1].position.y < 50 && el.value[0].children[1].position.y > 20) {
|
||||
el.value[0].children[1].position.y -= i
|
||||
} else if (el.value[0].children[1].position.y > 20) {
|
||||
el.value[0].children[1].position.y += i
|
||||
}
|
||||
// el.value[0].updateMatrixWorld()
|
||||
el.value[0]._needsUpdate = true
|
||||
})
|
||||
if (controls.value) {
|
||||
if (timer.value == 0) {
|
||||
|
@ -232,12 +224,12 @@ onAfterRender(() => {
|
|||
}
|
||||
})
|
||||
|
||||
let oldObj = []
|
||||
const passShader = (obj) => {
|
||||
if (obj.isMesh) {
|
||||
let oldObj = [] as { uuid: string, color: Color }[]
|
||||
const passShader = (obj: Mesh | Group) => {
|
||||
if (obj instanceof Mesh) {
|
||||
oldObj.push({ uuid: obj.uuid, color: obj.material.color })
|
||||
obj.material.color = new Color(1, 0, 0)
|
||||
} else {
|
||||
} else if (obj instanceof Group) {
|
||||
for (let c in obj.children) {
|
||||
passShader(obj.children[c])
|
||||
}
|
||||
|
@ -337,7 +329,7 @@ watch(() => sidebar_scene.list, () => {
|
|||
watch(() => sidebar.is_open, () => {
|
||||
if (sidebar.is_open == false) {
|
||||
oldObj.forEach(el => {
|
||||
const obj = seek(scene.value, 'uuid', el.uuid)
|
||||
const obj = seek(scene.value, 'uuid', el.uuid) as Mesh
|
||||
obj.material.color = el.color
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue