Skip to content
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

R144 #3768

Merged
merged 3 commits into from
Sep 1, 2022
Merged

R144 #3768

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 154 additions & 142 deletions package-lock.json

Large diffs are not rendered by default.

358 changes: 179 additions & 179 deletions packages/model-viewer/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/model-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"3d"
],
"dependencies": {
"three": "^0.143.0",
"three": "^0.144.0",
"lit": "^2.2.3"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import {Matrix4, Mesh, SphereBufferGeometry, Vector3} from 'three';
import {Matrix4, Mesh, SphereGeometry, Vector3} from 'three';

import {$scene} from '../../model-viewer-base.js';
import {ModelViewerElement} from '../../model-viewer.js';
Expand All @@ -33,7 +33,7 @@ suite('ModelScene', () => {
// Set the radius of the sphere to 0.5 so that it's size is 1
// for testing scaling.
dummyRadius = 0.5;
dummyMesh = new Mesh(new SphereBufferGeometry(dummyRadius, 32, 32));
dummyMesh = new Mesh(new SphereGeometry(dummyRadius, 32, 32));
element = new ModelViewerElement();
scene = element[$scene];

Expand Down
6 changes: 3 additions & 3 deletions packages/model-viewer/src/three-components/Debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import {Mesh, OrthographicCamera, PlaneBufferGeometry, Scene, ShaderMaterial, Texture, WebGLRenderTarget} from 'three';
import {Mesh, OrthographicCamera, PlaneGeometry, Scene, ShaderMaterial, Texture, WebGLRenderTarget} from 'three';

import {Constructor} from '../utilities.js';

Expand All @@ -24,7 +24,7 @@ export interface ModelViewerRendererDebugDetails {
renderer: Renderer;
THREE: {
ShaderMaterial: Constructor<ShaderMaterial>;
PlaneBufferGeometry: Constructor<PlaneBufferGeometry>;
PlaneGeometry: Constructor<PlaneGeometry>;
OrthographicCamera: Constructor<OrthographicCamera>;
WebGLRenderTarget: Constructor<WebGLRenderTarget>;
Texture: Constructor<Texture>;
Expand Down Expand Up @@ -63,7 +63,7 @@ export class Debugger {
Texture,
Mesh,
Scene,
PlaneBufferGeometry,
PlaneGeometry,
OrthographicCamera,
WebGLRenderTarget
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* limitations under the License.
*/

import {BackSide, BoxBufferGeometry, Mesh, MeshBasicMaterial, MeshStandardMaterial, PointLight, Scene} from 'three';
import {BackSide, BoxGeometry, Mesh, MeshBasicMaterial, MeshStandardMaterial, PointLight, Scene} from 'three';

export default class EnvironmentScene extends Scene {
constructor() {
super();

this.position.y = -3.5;

const geometry = new BoxBufferGeometry();
const geometry = new BoxGeometry();
geometry.deleteAttribute('uv');

const roomMaterial =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* limitations under the License.
*/

import {BackSide, BoxBufferGeometry, Mesh, MeshBasicMaterial, MeshStandardMaterial, PointLight, Scene} from 'three';
import {BackSide, BoxGeometry, Mesh, MeshBasicMaterial, MeshStandardMaterial, PointLight, Scene} from 'three';

export default class EnvironmentSceneAlt extends Scene {
constructor() {
super();

this.position.y = -3.5;

const geometry = new BoxBufferGeometry();
const geometry = new BoxGeometry();
geometry.deleteAttribute('uv');

const roomMaterial =
Expand Down
33 changes: 1 addition & 32 deletions packages/model-viewer/src/three-components/ModelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {BufferAttribute, InterleavedBufferAttribute, Object3D, Vector3} from 'three';


import {Object3D, Vector3} from 'three';

/**
* Gets a scale value to perform inverse quantization of a vertex value
* Reference:
* https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
* @param buffer A gltf vertex buffer
* @returns A scale value based on KHR_mesh_quantization or 1 if the buffer is
* not quantized.
*/
export const getNormalizedComponentScale =
(buffer: BufferAttribute|InterleavedBufferAttribute) => {
if (!buffer.normalized) {
return 1;
}

const array: ArrayLike<number> = buffer.array;
if (array instanceof Int8Array) {
return 1 / 127;
} else if (array instanceof Uint8Array) {
return 1 / 255;
} else if (array instanceof Int16Array) {
return 1 / 32767;
} else if (array instanceof Uint16Array) {
return 1 / 65535;
}
return 1;
};
/**
* Moves Three.js objects from one parent to another
*/
Expand Down Expand Up @@ -88,11 +60,8 @@ export const reduceVertices = <T>(
const {position} = geometry.attributes;

if (position !== undefined) {
const scale = getNormalizedComponentScale(position);

for (i = 0, l = position.count; i < l; i++) {
vertex.fromBufferAttribute(position, i);
vertex.multiplyScalar(scale);
if (object.isSkinnedMesh) {
object.boneTransform(i, vertex);
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/model-viewer/src/three-components/PlacementBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import {BufferGeometry, DoubleSide, Float32BufferAttribute, Material, Mesh, MeshBasicMaterial, PlaneBufferGeometry, Vector2, Vector3} from 'three';
import {BufferGeometry, DoubleSide, Float32BufferAttribute, Material, Mesh, MeshBasicMaterial, PlaneGeometry, Vector2, Vector3} from 'three';

import {Damper} from './Damper.js';
import {ModelScene} from './ModelScene.js';
Expand Down Expand Up @@ -100,7 +100,7 @@ export class PlacementBox extends Mesh {
this.opacityDamper = new Damper();

this.hitPlane =
new Mesh(new PlaneBufferGeometry(2 * (x + RADIUS), 2 * (y + RADIUS)));
new Mesh(new PlaneGeometry(2 * (x + RADIUS), 2 * (y + RADIUS)));
this.hitPlane.visible = false;
(this.hitPlane.material as Material).side = DoubleSide;
this.add(this.hitPlane);
Expand Down
4 changes: 2 additions & 2 deletions packages/model-viewer/src/three-components/Shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import {BackSide, Box3, Mesh, MeshBasicMaterial, MeshDepthMaterial, Object3D, OrthographicCamera, PlaneBufferGeometry, RGBAFormat, Scene, ShaderMaterial, Vector3, WebGLRenderer, WebGLRenderTarget, WebGLRenderTargetOptions} from 'three';
import {BackSide, Box3, Mesh, MeshBasicMaterial, MeshDepthMaterial, Object3D, OrthographicCamera, PlaneGeometry, RGBAFormat, Scene, ShaderMaterial, Vector3, WebGLRenderer, WebGLRenderTarget, WebGLRenderTargetOptions} from 'three';
import {HorizontalBlurShader} from 'three/examples/jsm/shaders/HorizontalBlurShader.js';
import {VerticalBlurShader} from 'three/examples/jsm/shaders/VerticalBlurShader.js';
import {lerp} from 'three/src/math/MathUtils.js';
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Shadow extends Object3D {
// this.matrixWorld = this.camera.matrixWorld;
// };

const plane = new PlaneBufferGeometry();
const plane = new PlaneGeometry();
const shadowMaterial = new MeshBasicMaterial({
// color: new Color(1, 0, 0),
opacity: 1,
Expand Down
4 changes: 2 additions & 2 deletions packages/model-viewer/src/three-components/TextureUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import {BackSide, BoxBufferGeometry, CubeCamera, CubeTexture, EquirectangularReflectionMapping, EventDispatcher, HalfFloatType, LinearEncoding, Mesh, NoBlending, NoToneMapping, RGBAFormat, Scene, ShaderMaterial, sRGBEncoding, Texture, TextureLoader, Vector3, WebGLCubeRenderTarget, WebGLRenderer} from 'three';
import {BackSide, BoxGeometry, CubeCamera, CubeTexture, EquirectangularReflectionMapping, EventDispatcher, HalfFloatType, LinearEncoding, Mesh, NoBlending, NoToneMapping, RGBAFormat, Scene, ShaderMaterial, sRGBEncoding, Texture, TextureLoader, Vector3, WebGLCubeRenderTarget, WebGLRenderer} from 'three';
import {RGBELoader} from 'three/examples/jsm/loaders/RGBELoader.js';

import {deserializeUrl, timePasses} from '../utilities.js';
Expand Down Expand Up @@ -199,7 +199,7 @@ export default class TextureUtils extends EventDispatcher {
private blurCubemap(cubeTarget: WebGLCubeRenderTarget, sigma: number) {
if (this.blurMaterial == null) {
this.blurMaterial = this.getBlurShader(MAX_SAMPLES);
const box = new BoxBufferGeometry();
const box = new BoxGeometry();
const blurMesh = new Mesh(box, this.blurMaterial!);
this.blurScene = new Scene();
this.blurScene.add(blurMesh);
Expand Down
84 changes: 42 additions & 42 deletions packages/modelviewer.dev/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading