-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EmissiveStrength and Clearcoat extensions #4319
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7beee02
EmissiveStrength and Clearcoat extensions
diegoteran c4eda51
Add Clearcoat Normal Texture Scale
diegoteran 706b6e3
Remove canonical GLTF element from ThreeDOMElement
diegoteran cc7a6b6
Cleanup for space-opera tests
diegoteran e14c82a
Address review comments.
diegoteran e672cf5
Reverted tests after adding name functionality
diegoteran 10eadec
Remove unused `|null` in some ThreeDOMElements
diegoteran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -16,55 +16,56 @@ | |
import {Mesh, MeshBasicMaterial, OrthographicCamera, PlaneGeometry, Scene, Texture as ThreeTexture, WebGLRenderTarget} from 'three'; | ||
|
||
import {blobCanvas} from '../../model-viewer-base.js'; | ||
import {Image as GLTFImage} from '../../three-components/gltf-instance/gltf-2.0.js'; | ||
import {Renderer} from '../../three-components/Renderer.js'; | ||
|
||
import {Image as ImageInterface} from './api.js'; | ||
import {$correlatedObjects, $onUpdate, $sourceObject, ThreeDOMElement} from './three-dom-element.js'; | ||
import {$correlatedObjects, $onUpdate, ThreeDOMElement} from './three-dom-element.js'; | ||
|
||
|
||
const quadMaterial = new MeshBasicMaterial(); | ||
const quad = new PlaneGeometry(2, 2); | ||
let adhocNum = 0; | ||
|
||
export const $threeTexture = Symbol('threeTexture'); | ||
export const $threeTextures = Symbol('threeTextures'); | ||
export const $applyTexture = Symbol('applyTexture'); | ||
|
||
/** | ||
* Image facade implementation for Three.js textures | ||
*/ | ||
export class Image extends ThreeDOMElement implements ImageInterface { | ||
get[$threeTexture]() { | ||
console.assert( | ||
this[$correlatedObjects] != null && this[$correlatedObjects]!.size > 0, | ||
'Image correlated object is undefined'); | ||
return this[$correlatedObjects]?.values().next().value as ThreeTexture; | ||
} | ||
|
||
constructor( | ||
onUpdate: () => void, texture: ThreeTexture|null, | ||
gltfImage: GLTFImage|null) { | ||
gltfImage = gltfImage ?? { | ||
name: (texture && texture.image && texture.image.src) ? | ||
get[$threeTextures](): Set<ThreeTexture> { | ||
return this[$correlatedObjects] as Set<ThreeTexture>; | ||
} | ||
|
||
constructor(onUpdate: () => void, texture: ThreeTexture) { | ||
super(onUpdate, new Set<ThreeTexture>(texture ? [texture] : [])); | ||
|
||
if (!this[$threeTexture].image.src) { | ||
this[$threeTexture].image.src = 'adhoc_image' + adhocNum++; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
if (!this[$threeTexture].image.name) { | ||
this[$threeTexture].image.name = | ||
(texture && texture.image && texture.image.src) ? | ||
texture.image.src.split('/').pop() : | ||
'adhoc_image', | ||
uri: (texture && texture.image && texture.image.src) ? | ||
texture.image.src : | ||
'adhoc_image' + adhocNum++ | ||
}; | ||
super(onUpdate, gltfImage, new Set<ThreeTexture>(texture ? [texture] : [])); | ||
'adhoc_image'; | ||
} | ||
} | ||
|
||
get name(): string { | ||
return (this[$sourceObject] as GLTFImage).name || ''; | ||
return this[$threeTexture].image.name || ''; | ||
} | ||
|
||
get uri(): string|undefined { | ||
return (this[$sourceObject] as GLTFImage).uri; | ||
return this[$threeTexture].image.src; | ||
} | ||
|
||
get bufferView(): number|undefined { | ||
return (this[$sourceObject] as GLTFImage).bufferView; | ||
return this[$threeTexture].image.bufferView; | ||
} | ||
|
||
get element(): HTMLVideoElement|HTMLCanvasElement|undefined { | ||
|
@@ -88,7 +89,9 @@ export class Image extends ThreeDOMElement implements ImageInterface { | |
} | ||
|
||
set name(name: string) { | ||
(this[$sourceObject] as GLTFImage).name = name; | ||
for (const texture of this[$threeTextures]) { | ||
texture.image.name = name; | ||
} | ||
} | ||
|
||
update() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you still planning to rename
$correlatedObjects
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "correlated" name comes from the default correlation through the gltfMap from ThreeJS Loader:
model-viewer/packages/model-viewer/src/features/scene-graph/model.ts
Line 96 in 8546f41
I'm not sure if the name should change.