|
@@ -4,6 +4,8 @@ import {
|
|
setupDevtoolsPlugin,
|
|
setupDevtoolsPlugin,
|
|
} from '@vue/devtools-api'
|
|
} from '@vue/devtools-api'
|
|
import { reactive } from 'vue'
|
|
import { reactive } from 'vue'
|
|
|
|
+import type { Mesh, Object3D } from 'three'
|
|
|
|
+import { animateHighlight, createHighlightMesh, editSceneObject } from '../utils'
|
|
import { bytesToKB, calculateMemoryUsage } from '../utils/perf'
|
|
import { bytesToKB, calculateMemoryUsage } from '../utils/perf'
|
|
import type { TresContext } from '../composables'
|
|
import type { TresContext } from '../composables'
|
|
import type { TresObject } from './../types'
|
|
import type { TresObject } from './../types'
|
|
@@ -116,6 +118,7 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
|
|
(api) => {
|
|
(api) => {
|
|
if (typeof api.now !== 'function') {
|
|
if (typeof api.now !== 'function') {
|
|
toastMessage(
|
|
toastMessage(
|
|
|
|
+ // eslint-disable-next-line max-len
|
|
'You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.',
|
|
'You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.',
|
|
)
|
|
)
|
|
}
|
|
}
|
|
@@ -131,6 +134,10 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
|
|
api.sendInspectorTree(INSPECTOR_ID)
|
|
api.sendInspectorTree(INSPECTOR_ID)
|
|
}, 1000)
|
|
}, 1000)
|
|
|
|
|
|
|
|
+ setInterval(() => {
|
|
|
|
+ api.notifyComponentUpdate()
|
|
|
|
+ }, 5000)
|
|
|
|
+
|
|
api.on.getInspectorTree((payload) => {
|
|
api.on.getInspectorTree((payload) => {
|
|
if (payload.inspectorId === INSPECTOR_ID) {
|
|
if (payload.inspectorId === INSPECTOR_ID) {
|
|
// Your logic here
|
|
// Your logic here
|
|
@@ -164,43 +171,58 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
|
|
] */
|
|
] */
|
|
}
|
|
}
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+ let highlightMesh: Mesh | null = null
|
|
|
|
+ let prevInstance: Object3D | null = null
|
|
|
|
+
|
|
api.on.getInspectorState((payload) => {
|
|
api.on.getInspectorState((payload) => {
|
|
if (payload.inspectorId === INSPECTOR_ID) {
|
|
if (payload.inspectorId === INSPECTOR_ID) {
|
|
// Your logic here
|
|
// Your logic here
|
|
const [instance] = tres.scene.value.getObjectsByProperty('uuid', payload.nodeId)
|
|
const [instance] = tres.scene.value.getObjectsByProperty('uuid', payload.nodeId)
|
|
|
|
+ if (!instance) return
|
|
|
|
+ if (prevInstance && highlightMesh && highlightMesh.parent) {
|
|
|
|
+ prevInstance.remove(highlightMesh)
|
|
|
|
+ }
|
|
|
|
+ const newHighlightMesh = createHighlightMesh(instance)
|
|
|
|
+ instance.add(newHighlightMesh)
|
|
|
|
+
|
|
|
|
+ // Start the animation
|
|
|
|
+ const startTime = Date.now()
|
|
|
|
+ animateHighlight(newHighlightMesh, startTime)
|
|
|
|
|
|
|
|
+ highlightMesh = newHighlightMesh
|
|
|
|
+ prevInstance = instance
|
|
|
|
+
|
|
if (instance) {
|
|
if (instance) {
|
|
payload.state = {
|
|
payload.state = {
|
|
object: [
|
|
object: [
|
|
{
|
|
{
|
|
key: 'uuid',
|
|
key: 'uuid',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.uuid,
|
|
value: instance.uuid,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'name',
|
|
key: 'name',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.name,
|
|
value: instance.name,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'type',
|
|
key: 'type',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.type,
|
|
value: instance.type,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'position',
|
|
key: 'position',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.position,
|
|
value: instance.position,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'rotation',
|
|
key: 'rotation',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.rotation,
|
|
value: instance.rotation,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'scale',
|
|
key: 'scale',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.scale,
|
|
value: instance.scale,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -213,37 +235,37 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'color',
|
|
key: 'color',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.color,
|
|
value: instance.color,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'intensity',
|
|
key: 'intensity',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.intensity,
|
|
value: instance.intensity,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'castShadow',
|
|
key: 'castShadow',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.castShadow,
|
|
value: instance.castShadow,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'receiveShadow',
|
|
key: 'receiveShadow',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.receiveShadow,
|
|
value: instance.receiveShadow,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'frustumCulled',
|
|
key: 'frustumCulled',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.frustumCulled,
|
|
value: instance.frustumCulled,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'matrixAutoUpdate',
|
|
key: 'matrixAutoUpdate',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.matrixAutoUpdate,
|
|
value: instance.matrixAutoUpdate,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'matrixWorldNeedsUpdate',
|
|
key: 'matrixWorldNeedsUpdate',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.matrixWorldNeedsUpdate,
|
|
value: instance.matrixWorldNeedsUpdate,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -253,9 +275,8 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
|
|
|
|
|
|
{
|
|
{
|
|
key: 'visible',
|
|
key: 'visible',
|
|
- editable: false,
|
|
|
|
|
|
+ editable: true,
|
|
value: instance.visible,
|
|
value: instance.visible,
|
|
-
|
|
|
|
},
|
|
},
|
|
],
|
|
],
|
|
}
|
|
}
|
|
@@ -263,7 +284,12 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
|
|
|
|
|
|
}
|
|
}
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ api.on.editInspectorState((payload) => {
|
|
|
|
+ if (payload.inspectorId === INSPECTOR_ID) {
|
|
|
|
+ editSceneObject(tres.scene.value, payload.nodeId, payload.path, payload.state.value)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
)
|
|
)
|
|
}
|
|
}
|