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

Examples: Update model in glTF AVIF demo. #25708

Merged
merged 2 commits into from
Mar 23, 2023
Merged
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
Binary file removed examples/models/gltf/AVIFTest/DamagedHelmetAVIF.glb
Binary file not shown.
Binary file removed examples/models/gltf/AVIFTest/avif-test.avif
Binary file not shown.
Binary file removed examples/models/gltf/AVIFTest/avif-test.bin
Binary file not shown.
134 changes: 0 additions & 134 deletions examples/models/gltf/AVIFTest/avif-test.gltf

This file was deleted.

Binary file added examples/models/gltf/AVIFTest/forest_house.glb
Binary file not shown.
Binary file modified examples/screenshots/webgl_loader_gltf_avif.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 34 additions & 46 deletions examples/webgl_loader_gltf_avif.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
<head>
<title>three.js webgl - GLTFloader + EXT_texture_avif</title>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
/>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
<link type="text/css" rel="stylesheet" href="main.css" />
<style>
body {
background-color: #bfe3dd;
color: #000;
}

a {
color: #986b60;
}
</style>
</head>

<body>
<div id="info">
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a>
- GLTFLoader +
<a
href="https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_texture_avif"
target="_blank"
rel="noopener"
>EXT_texture_avif</a
><br />
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - GLTFLoader +
<a href="https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_texture_avif" target="_blank" rel="noopener" >EXT_texture_avif</a><br />
Forest House by <a href="https://sketchfab.com/peachyroyalty" target="_blank" rel="noopener">peachyroyalty</a><br />
</div>

<!-- Import maps polyfill -->
Expand All @@ -40,7 +42,7 @@

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';

let camera, scene, renderer;

Expand All @@ -49,56 +51,42 @@

function init() {

const container = document.createElement( 'div' );
document.body.appendChild( container );

camera = new THREE.PerspectiveCamera(
45,
window.innerWidth / window.innerHeight,
0.25,
20
);
camera.position.set( 2.5, 0, 3.0 );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 100 );
camera.position.set( 0, 8, 12 );

scene = new THREE.Scene();
scene.background = new THREE.Color( 0xf6eedc );

new RGBELoader()
.setPath( 'textures/equirectangular/' )
.load( 'quarry_01_1k.hdr', function ( texture ) {

texture.mapping = THREE.EquirectangularReflectionMapping;

scene.background = texture;
scene.environment = texture;
//

render();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath( 'jsm/libs/draco/gltf/' );

// model
const loader = new GLTFLoader();
loader.setDRACOLoader( dracoLoader );
loader.setPath( 'models/gltf/AVIFTest/' );
loader.load( 'forest_house.glb', function ( gltf ) {

const loader = new GLTFLoader().setPath( 'models/gltf/AVIFTest/' );
loader.load( 'DamagedHelmetAVIF.glb', function ( gltf ) {
gltf.scene.scale.multiplyScalar( 40 );
gltf.scene.rotation.y = Math.PI * 0.5;

scene.add( gltf.scene );
scene.add( gltf.scene );

render();
render();

} );
} );

} );
//

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1;
renderer.outputEncoding = THREE.sRGBEncoding;
container.appendChild( renderer.domElement );
document.body.appendChild( renderer.domElement );

const controls = new OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render ); // use if there is no animation loop
controls.minDistance = 2;
controls.maxDistance = 10;
controls.target.set( 0, 0, 0);
controls.addEventListener( 'change', render );
controls.target.set( 0, 2, 0 );
controls.update();

window.addEventListener( 'resize', onWindowResize );
Expand Down