no message

This commit is contained in:
hawk86104 2024-05-14 17:08:54 +08:00
parent 5fe89ebe4b
commit 2b8c551df3
2 changed files with 29 additions and 20 deletions

View File

@ -66,23 +66,27 @@ player.init(tresScene, renderer, camera, sizes)
const loader = new THREE.ObjectLoader()
const scene = await loadJson('./plugins/${pluginName}/json/scene.json')
for (const geometry of scene.geometries) {
if (geometry.data.startsWith('url:')) {
let url = geometry.data.slice(4)
if (url.startsWith('geometries/')) {
url = \`./plugins/${pluginName}/\${url}\`
}
geometry.data = await loadJson(url)
}
if (scene.geometries) {
for (const geometry of scene.geometries) {
if (geometry.data && geometry.data.startsWith('url:')) {
let url = geometry.data.slice(4)
if (url.startsWith('geometries/')) {
url = \`./plugins/${pluginName}/\${url}\`
}
geometry.data = await loadJson(url)
}
}
}
for (const image of scene.images) {
if (image.url.startsWith('url:')) {
let url = image.url.slice(4)
if (url.startsWith('images/')) {
url = \`./plugins/${pluginName}/\${url}\`
}
image.url = await convertImageToBase64(url)
}
if (scene.images) {
for (const image of scene.images) {
if (image.url && image.url.startsWith('url:')) {
let url = image.url.slice(4)
if (url.startsWith('images/')) {
url = \`./plugins/${pluginName}/\${url}\`
}
image.url = await convertImageToBase64(url)
}
}
}
const group = ref(null) as any
@ -95,7 +99,7 @@ watch(
tresScene.value.background = sceneObject.background
tresScene.value.environment = sceneObject.environment
tresScene.value.fog = sceneObject.fog
player.load()
player.load(sceneObject)
player.play()
}
},

View File

@ -39,7 +39,7 @@ const player = {
Grscwh.camera = camera
Grscwh.sizes = sizes
},
load() {
load(sceneObject) {
${scriptsJson}
this.events = {
init: [],
@ -61,9 +61,14 @@ const player = {
}
const scriptWrapResult = JSON.stringify(scriptWrapResultObj).replace(/\\"/g, '')
for (const uuid in scriptsJson) {
const object = this.scene.getObjectByProperty('uuid', uuid, true)
let curUuid = uuid
//这里解决一个问题 目前并没有把 主场景scene直接替换而是通过group 加进入的,所以 如果事件是基于主场景scene 那么替换这个uuid为现在tres主场景的uuid
if (uuid === sceneObject.uuid) {
curUuid = this.scene.uuid
}
const object = this.scene.getObjectByProperty('uuid', curUuid, true)
if (object === undefined) {
console.warn('player: Script without object.', uuid)
console.warn('player: Script without object.', curUuid)
continue
}
const scripts = scriptsJson[uuid]