Skip to content

Implement align-model attribute - #441

Merged
cdata merged 3 commits into
masterfrom
confirable-origin
Mar 24, 2019
Merged

cdata merged 3 commits into
masterfrom
confirable-origin

Conversation

@cdata

@cdata cdata commented Mar 22, 2019 •

Copy link
Copy Markdown
Contributor

align-model attribute


This change proposes a new configurable attribute align-model that can change how the model is aligned relative to the scene. Important highlights include:

  • align-model accepts values center and origin
    • center refers to the center of the bounding volume of the model
    • origin refers to the origin of the model relative to world space
    • Accepts two- or three-value formats in the spirit of CSS properties like transform-origin
    • For two-value form, the first value is also used to fill in the third value
  • align-model and auto-rotate have been conceptually grouped together as the "staging" feature
  • Fixed a bug related to bleeding lighting configuration (see Materials not being cloned correctly #440)
  • A handful of additional memory leak sources were squashed in the test suite

🛂Note for reviewers: I have spent a lot of time noodling on the names. I do not love any of them. Please don't hesitate to bike shed!

Different values of align-model

center (default) origin origin center center origin center
image image image image

Fixes #417
Fixes #440
Includes further mitigations related to #433

@cdata
cdata force-pushed the confirable-origin branch 2 times, most recently from 6f75835 to cdb3e4d Compare March 22, 2019 16:56
@cdata
cdata force-pushed the confirable-origin branch from cdb3e4d to bc546c7 Compare March 23, 2019 00:48
@cdata
cdata marked this pull request as ready for review March 23, 2019 01:11
@cdata
cdata requested review from jsantell, mrdoob and smalls March 23, 2019 01:13
jsantell
jsantell previously approved these changes Mar 23, 2019
Comment thread src/model-viewer.js
StagingMixin,
ControlsMixin,
EnvironmentMixin,
StagingMixin,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like StagingMixin is in here twice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, will fix!

// NOTE(cdata): In the case that the generators are invoked with
// an incorrect texture, the generators will throw when we attempt to
// dispose of them because the framebuffer has not been created yet but the
// implementation does not guard for this correctly:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 great catch

Comment thread src/three-components/ModelScene.js Outdated
modelCenter.multiplyScalar(scale);

this.model.scale.multiplyScalar(scale);
this.model.position.copy(roomCenter);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems redundant due to the following subVectors

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix

const {exposure} = scene;
const exposureIsNumber =
typeof exposure === 'number' && !self.isNaN(exposure);
this.renderer.toneMappingExposure = exposureIsNumber ? exposure : 1.0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here too, exposure is scene specific

@cdata
cdata force-pushed the confirable-origin branch from bebc1b4 to f39af84 Compare March 24, 2019 06:03
@cdata
cdata merged commit e4565fa into master Mar 24, 2019
@cdata
cdata deleted the confirable-origin branch March 24, 2019 07:11
@smalls

smalls commented Mar 25, 2019 •

Copy link
Copy Markdown
Contributor

🚲 🏚️ ... Sorry I didn't get this into #417 while we were still discussing there.

In some ways, at least as I look at the illustration above, it seems as though what the transformation is doing is changing how the scene is composed around the model. I wonder if an attribute of scene-alignment or scene-origin, with values model-center or model-origin might communicate that?

Since this has already been merged, feel free to ignore :)

@cdata

cdata commented Mar 25, 2019

Copy link
Copy Markdown
Contributor Author

@smalls thanks for the feedback! At this point the most useful thing is probably to file an issue so that we revisit this before the next major release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants