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