This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rewrite reactive UVOL1 * Move worker to engine scope, refactor to use hooks, improve playlist mechanism * Autoplay/paused fixes * wip: init UniformUVOL * fetch geometry segments and textures * unifying non-uniform and uniform component * Dispose attributes on GPU, track management * clean up * Update meshopt decoder module `meshopt_decoder.module.js` stringifies some functions and spawns workers. Production build optimizes these files and changes the function names, which causes issues. It's better if we just hand over the function source, instead of stringifying. * UVOL1 readability * Loading effect for UVOL1 * Mirror media element paused * Add explicit `autoplay` property Now: - `handleAutoplay()` calls media.play() synchronously. - It also sets volumetric.paused to true. - It cleans up event listeners after the media is played. * Cleaned up pause/autoplay logic - Overall improvements to UVOL1 Loading effect - Show the first frame without waiting for the whole initial buffers * minor correction to buffering logic * Implement consistent and reliable loading effect * revert AvatarDissolveComponent's changes * Autotune targets * disable shadows for uniform solve * improve initial loading logic * improve blending keyframes * Improve setAttribute attributes should not be disposed when setting keyframeB. Because it'll be used by keyframeA in the next frame. * Dont play when sufficient buffers not loaded yet * Improve performance - Stricter heuristic for autotuning targets - Upload the textures (with initTexture) to GPU as soon as they're decoded. - Doing this at render time will cause some lag * Move CORTOLoader to AssetLoaderState * Update shader to r157 * Start UVOL2 at non-zero time Also fixed the pause being overwritten by snapshot * Support different segment sizes across targets --------- Co-authored-by: Gheric Speiginer <gheric.speiginer@gmail.com>
- Loading branch information
1 parent
a502c48
commit 1889fb4
Showing
15 changed files
with
3,584 additions
and
372 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
|
||
import { BufferGeometry, Loader, LoadingManager } from 'three' | ||
|
||
export class CORTOLoader { | ||
constructor() | ||
setDecoderPath(path: string): CORTOLoader | ||
load( | ||
url: string, | ||
byteStart: number, | ||
byteEnd: number, | ||
onLoad: (geometry: BufferGeometry | null) => void, | ||
): void | ||
preload(): Promise<void> | ||
dispose(): CORTOLoader | ||
} |
130 changes: 130 additions & 0 deletions
130
packages/engine/src/assets/loaders/corto/CORTOLoader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
|
||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
|
||
import { BufferAttribute, BufferGeometry, FileLoader } from 'three' | ||
|
||
class CORTOLoader { | ||
constructor() { | ||
this.decoderPath = '' | ||
this.decoderPending = null | ||
|
||
this.worker = null | ||
this.lastRequest = 0 | ||
this.callbacks = {} | ||
|
||
this.defaultAttributes = [ | ||
{ name: 'position', numComponents: '3' }, | ||
{ name: 'normal', numComponents: '3' }, | ||
{ name: 'color', numComponents: '4' }, | ||
{ name: 'uv', numComponents: '2' } | ||
] | ||
} | ||
|
||
setDecoderPath(path) { | ||
this.decoderPath = path | ||
return this | ||
} | ||
|
||
load(url, byteStart, byteEnd, onLoad) { | ||
if (!this.decoderPending) { | ||
this.preload() | ||
} | ||
|
||
this.decoderPending.then(() => { | ||
const request = this.lastRequest++ | ||
this.worker.postMessage({ | ||
request: request, | ||
url: url, | ||
byteStart: byteStart, | ||
byteEnd: byteEnd | ||
}) | ||
this.callbacks[request] = { onLoad: onLoad } | ||
}) | ||
} | ||
|
||
preload() { | ||
if (this.decoderPending) return this.decoderPending | ||
|
||
let that = this | ||
let callbacks = this.callbacks | ||
let lib = 'corto.js' | ||
|
||
this.decoderPending = this._loadLibrary(lib, 'text').then((text) => { | ||
text = URL.createObjectURL(new Blob([text])) | ||
this.worker = new Worker(text) | ||
|
||
this.worker.onmessage = function (e) { | ||
var message = e.data | ||
if (!callbacks[message.request]) return | ||
|
||
const callback = callbacks[message.request] | ||
const geometry = that._createGeometry(message.geometry) | ||
callback.onLoad(geometry) | ||
delete callbacks[message.request] | ||
} | ||
}) | ||
|
||
return this.decoderPending | ||
} | ||
|
||
dispose() { | ||
if (this.worker) { | ||
this.worker.terminate() | ||
this.worker = null | ||
} | ||
return this | ||
} | ||
|
||
_createGeometry(geometry) { | ||
if (!geometry) { | ||
return null | ||
} | ||
var bufferGeometry = new BufferGeometry() | ||
|
||
if (geometry.index) bufferGeometry.setIndex(new BufferAttribute(geometry.index, 1)) | ||
|
||
for (let i = 0; i < this.defaultAttributes.length; i++) { | ||
let attr = this.defaultAttributes[i] | ||
if (!geometry[attr.name]) continue | ||
let buffer = geometry[attr.name] | ||
bufferGeometry.setAttribute(attr.name, new BufferAttribute(buffer, attr.numComponents)) | ||
} | ||
return bufferGeometry | ||
} | ||
|
||
_loadLibrary(url, responseType) { | ||
var loader = new FileLoader(this.manager) | ||
loader.setPath(this.decoderPath) | ||
loader.setResponseType(responseType) | ||
|
||
return new Promise((resolve, reject) => { | ||
loader.load(url, resolve, undefined, reject) | ||
}) | ||
} | ||
} | ||
|
||
export { CORTOLoader } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
330 changes: 205 additions & 125 deletions
330
packages/engine/src/assets/loaders/gltf/meshopt_decoder.module.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.