Skip to content
Open
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
10 changes: 5 additions & 5 deletions packages/model-viewer/src/three-components/TextureUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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

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

Expand All @@ -40,7 +40,7 @@ export default class TextureUtils {

private _ldrLoader: TextureLoader|null = null;
private _imageLoader: HDRJPGLoader|null = null;
private _hdrLoader: HDRLoader|null = null;
private _hdrLoader: RGBELoader|null = null;
private _lottieLoader: Loader|null = null;

private generatedEnvironmentMap: Promise<CubeTexture>|null = null;
Expand Down Expand Up @@ -70,9 +70,9 @@ export default class TextureUtils {
return this._imageLoader;
}

private hdrLoader(withCredentials: boolean): HDRLoader {
private hdrLoader(withCredentials: boolean): RGBELoader {
if (this._hdrLoader == null) {
this._hdrLoader = new HDRLoader();
this._hdrLoader = new RGBELoader();
this._hdrLoader.setDataType(HalfFloatType);
}
this._hdrLoader.setWithCredentials(withCredentials);
Expand Down Expand Up @@ -136,7 +136,7 @@ export default class TextureUtils {
const texture: Texture = await new Promise<Texture>(
(resolve, reject) => loader.load(
url,
(result) => {
(result: any) => {
const {renderTarget} =
result as QuadRenderer<1016, GainMapDecoderMaterial>;
if (renderTarget != null) {
Expand Down
46 changes: 37 additions & 9 deletions packages/modelviewer.dev/examples/loading/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ <h4></h4>
transform: translate3d(-50%, -50%, 0);
z-index: 100;
}

.controls {
position: absolute;
display: flex;
flex-direction: column;
align-items: left;
bottom: 8px;
left: 8px;
}
</style>
<!-- use unique asset to ensure lazy loading -->
<model-viewer id="lazy-load" camera-controls touch-action="pan-y" reveal="manual"
Expand Down Expand Up @@ -433,8 +424,45 @@ <h4>Our renderer tries to keep the frame rate between 38 and 60 frames per secon
</div>
<example-snippet stamp-to="renderScale" highlight-as="html">
<template>
<style>
model-viewer#scale {
container-type: size;
}
.controls {
position: absolute;
display: flex;
flex-direction: column;
align-items: flex-start;
bottom: 16px;
left: 16px;
z-index: 10;
}
.custom-ar-button {
position: absolute;
top: 16px;
right: 16px;
background-color: white;
border: 1px solid #dadce0;
border-radius: 4px;
padding: 8px 12px;
font-weight: 500;
font-size: 14px;
color: #1a73e8;
box-shadow: 0 2px 4px rgba(0,0,0,.1);
cursor: pointer;
z-index: 10;
transform: translateY(calc(100cqh - 100% - 32px));
transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@container (max-width: 700px) {
.custom-ar-button {
transform: translateY(0px);
}
}
</style>
<model-viewer id="scale" alt="A 3D model of a toy car" camera-controls touch-action="pan-y" auto-rotate
src="../../shared-assets/models/glTF-Sample-Assets/Models/ToyCar/glTF-Binary/ToyCar.glb" ar>
<button slot="ar-button" class="custom-ar-button">View in AR</button>
<div class="controls glass">
<div>
Reported DPR: <span id="reportedDpr"></span>
Expand Down
Loading