Skip to content

Commit 9396323

Browse files
authored
Fix AR button overlap on Dynamic Scaling page and resolve HDR bundle bug (#5145)
1 parent e6ac9dd commit 9396323

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

packages/model-viewer/src/three-components/TextureUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import {GainMapDecoderMaterial, HDRJPGLoader, QuadRenderer} from '@monogrid/gainmap-js';
1717
import {BackSide, BoxGeometry, CubeCamera, CubeTexture, DataTexture, EquirectangularReflectionMapping, HalfFloatType, LinearSRGBColorSpace, Loader, Mesh, NoBlending, NoToneMapping, RGBAFormat, Scene, ShaderMaterial, SRGBColorSpace, Texture, TextureLoader, Vector3, WebGLCubeRenderTarget, WebGLRenderer} from 'three';
18-
import {HDRLoader} from 'three/examples/jsm/loaders/HDRLoader.js';
18+
import {RGBELoader} from 'three/examples/jsm/loaders/RGBELoader.js';
1919

2020
import {deserializeUrl, timePasses} from '../utilities.js';
2121

@@ -40,7 +40,7 @@ export default class TextureUtils {
4040

4141
private _ldrLoader: TextureLoader|null = null;
4242
private _imageLoader: HDRJPGLoader|null = null;
43-
private _hdrLoader: HDRLoader|null = null;
43+
private _hdrLoader: RGBELoader|null = null;
4444
private _lottieLoader: Loader|null = null;
4545

4646
private generatedEnvironmentMap: Promise<CubeTexture>|null = null;
@@ -70,9 +70,9 @@ export default class TextureUtils {
7070
return this._imageLoader;
7171
}
7272

73-
private hdrLoader(withCredentials: boolean): HDRLoader {
73+
private hdrLoader(withCredentials: boolean): RGBELoader {
7474
if (this._hdrLoader == null) {
75-
this._hdrLoader = new HDRLoader();
75+
this._hdrLoader = new RGBELoader();
7676
this._hdrLoader.setDataType(HalfFloatType);
7777
}
7878
this._hdrLoader.setWithCredentials(withCredentials);
@@ -136,7 +136,7 @@ export default class TextureUtils {
136136
const texture: Texture = await new Promise<Texture>(
137137
(resolve, reject) => loader.load(
138138
url,
139-
(result) => {
139+
(result: any) => {
140140
const {renderTarget} =
141141
result as QuadRenderer<1016, GainMapDecoderMaterial>;
142142
if (renderTarget != null) {

packages/modelviewer.dev/examples/loading/index.html

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,6 @@ <h4></h4>
114114
transform: translate3d(-50%, -50%, 0);
115115
z-index: 100;
116116
}
117-
118-
.controls {
119-
position: absolute;
120-
display: flex;
121-
flex-direction: column;
122-
align-items: left;
123-
bottom: 8px;
124-
left: 8px;
125-
}
126117
</style>
127118
<!-- use unique asset to ensure lazy loading -->
128119
<model-viewer id="lazy-load" camera-controls touch-action="pan-y" reveal="manual"
@@ -433,6 +424,26 @@ <h4>Our renderer tries to keep the frame rate between 38 and 60 frames per secon
433424
</div>
434425
<example-snippet stamp-to="renderScale" highlight-as="html">
435426
<template>
427+
<style>
428+
model-viewer#scale {
429+
container-type: size;
430+
}
431+
.controls {
432+
position: absolute;
433+
display: flex;
434+
flex-direction: column;
435+
align-items: flex-start;
436+
top: 16px;
437+
left: 16px;
438+
transform: translateY(calc(100cqh - 100% - 32px));
439+
transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
440+
}
441+
@container (max-width: 550px) {
442+
.controls {
443+
transform: translateY(0px);
444+
}
445+
}
446+
</style>
436447
<model-viewer id="scale" alt="A 3D model of a toy car" camera-controls touch-action="pan-y" auto-rotate
437448
src="../../shared-assets/models/glTF-Sample-Assets/Models/ToyCar/glTF-Binary/ToyCar.glb" ar>
438449
<div class="controls glass">

0 commit comments

Comments
 (0)