[object Object]

← back to Quadrille Showroom

auto-save: 2026-06-30T20:43:13 (9 files) — public/js/showroom.js public/js/viewmodes.js public/showroom.html public/js/GLTFLoader.js public/models/

02a9c214d8495ca94de0db7a04ef8c8b3a36e94d · 2026-06-30 20:43:16 -0700 · Steve Abrams

Files touched

Diff

commit 02a9c214d8495ca94de0db7a04ef8c8b3a36e94d
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jun 30 20:43:16 2026 -0700

    auto-save: 2026-06-30T20:43:13 (9 files) — public/js/showroom.js public/js/viewmodes.js public/showroom.html public/js/GLTFLoader.js public/models/
---
 public/js/GLTFLoader.js        | 3629 ++++++++++++++++++++++++++++++++++++++++
 public/js/showroom.js          |  800 ++++++++-
 public/js/viewmodes.js         |   63 +
 public/models/CREDITS.md       |   43 +
 public/models/office-chair.glb |  Bin 0 -> 4125648 bytes
 public/models/sofa.glb         |  Bin 0 -> 10107912 bytes
 public/showroom.html           |   12 +
 scripts/gitify-phase2.sh       |   25 +
 scripts/glbcheck.cjs           |    8 +
 scripts/syntax-check.cjs       |   18 +
 scripts/verify-roomtypes.mjs   |   90 +
 11 files changed, 4683 insertions(+), 5 deletions(-)

diff --git a/public/js/GLTFLoader.js b/public/js/GLTFLoader.js
new file mode 100644
index 0000000..cfa518e
--- /dev/null
+++ b/public/js/GLTFLoader.js
@@ -0,0 +1,3629 @@
+( function () {
+
+	class GLTFLoader extends THREE.Loader {
+
+		constructor( manager ) {
+
+			super( manager );
+			this.dracoLoader = null;
+			this.ktx2Loader = null;
+			this.meshoptDecoder = null;
+			this.pluginCallbacks = [];
+			this.register( function ( parser ) {
+
+				return new GLTFMaterialsClearcoatExtension( parser );
+
+			} );
+			this.register( function ( parser ) {
+
+				return new GLTFTextureBasisUExtension( parser );
+
+			} );
+			this.register( function ( parser ) {
+
+				return new GLTFTextureWebPExtension( parser );
+
+			} );
+			this.register( function ( parser ) {
+
+				return new GLTFMaterialsTransmissionExtension( parser );
+
+			} );
+			this.register( function ( parser ) {
+
+				return new GLTFLightsExtension( parser );
+
+			} );
+			this.register( function ( parser ) {
+
+				return new GLTFMeshoptCompression( parser );
+
+			} );
+
+		}
+
+		load( url, onLoad, onProgress, onError ) {
+
+			const scope = this;
+			let resourcePath;
+
+			if ( this.resourcePath !== '' ) {
+
+				resourcePath = this.resourcePath;
+
+			} else if ( this.path !== '' ) {
+
+				resourcePath = this.path;
+
+			} else {
+
+				resourcePath = THREE.LoaderUtils.extractUrlBase( url );
+
+			} // Tells the LoadingManager to track an extra item, which resolves after
+			// the model is fully loaded. This means the count of items loaded will
+			// be incorrect, but ensures manager.onLoad() does not fire early.
+
+
+			this.manager.itemStart( url );
+
+			const _onError = function ( e ) {
+
+				if ( onError ) {
+
+					onError( e );
+
+				} else {
+
+					console.error( e );
+
+				}
+
+				scope.manager.itemError( url );
+				scope.manager.itemEnd( url );
+
+			};
+
+			const loader = new THREE.FileLoader( this.manager );
+			loader.setPath( this.path );
+			loader.setResponseType( 'arraybuffer' );
+			loader.setRequestHeader( this.requestHeader );
+			loader.setWithCredentials( this.withCredentials );
+			loader.load( url, function ( data ) {
+
+				try {
+
+					scope.parse( data, resourcePath, function ( gltf ) {
+
+						onLoad( gltf );
+						scope.manager.itemEnd( url );
+
+					}, _onError );
+
+				} catch ( e ) {
+
+					_onError( e );
+
+				}
+
+			}, onProgress, _onError );
+
+		}
+
+		setDRACOLoader( dracoLoader ) {
+
+			this.dracoLoader = dracoLoader;
+			return this;
+
+		}
+
+		setDDSLoader() {
+
+			throw new Error( 'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".' );
+
+		}
+
+		setKTX2Loader( ktx2Loader ) {
+
+			this.ktx2Loader = ktx2Loader;
+			return this;
+
+		}
+
+		setMeshoptDecoder( meshoptDecoder ) {
+
+			this.meshoptDecoder = meshoptDecoder;
+			return this;
+
+		}
+
+		register( callback ) {
+
+			if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
+
+				this.pluginCallbacks.push( callback );
+
+			}
+
+			return this;
+
+		}
+
+		unregister( callback ) {
+
+			if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
+
+				this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 );
+
+			}
+
+			return this;
+
+		}
+
+		parse( data, path, onLoad, onError ) {
+
+			let content;
+			const extensions = {};
+			const plugins = {};
+
+			if ( typeof data === 'string' ) {
+
+				content = data;
+
+			} else {
+
+				const magic = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
+
+				if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
+
+					try {
+
+						extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
+
+					} catch ( error ) {
+
+						if ( onError ) onError( error );
+						return;
+
+					}
+
+					content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
+
+				} else {
+
+					content = THREE.LoaderUtils.decodeText( new Uint8Array( data ) );
+
+				}
+
+			}
+
+			const json = JSON.parse( content );
+
+			if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
+
+				if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
+				return;
+
+			}
+
+			const parser = new GLTFParser( json, {
+				path: path || this.resourcePath || '',
+				crossOrigin: this.crossOrigin,
+				requestHeader: this.requestHeader,
+				manager: this.manager,
+				ktx2Loader: this.ktx2Loader,
+				meshoptDecoder: this.meshoptDecoder
+			} );
+			parser.fileLoader.setRequestHeader( this.requestHeader );
+
+			for ( let i = 0; i < this.pluginCallbacks.length; i ++ ) {
+
+				const plugin = this.pluginCallbacks[ i ]( parser );
+				plugins[ plugin.name ] = plugin; // Workaround to avoid determining as unknown extension
+				// in addUnknownExtensionsToUserData().
+				// Remove this workaround if we move all the existing
+				// extension handlers to plugin system
+
+				extensions[ plugin.name ] = true;
+
+			}
+
+			if ( json.extensionsUsed ) {
+
+				for ( let i = 0; i < json.extensionsUsed.length; ++ i ) {
+
+					const extensionName = json.extensionsUsed[ i ];
+					const extensionsRequired = json.extensionsRequired || [];
+
+					switch ( extensionName ) {
+
+						case EXTENSIONS.KHR_MATERIALS_UNLIT:
+							extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
+							break;
+
+						case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
+							extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
+							break;
+
+						case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
+							extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
+							break;
+
+						case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
+							extensions[ extensionName ] = new GLTFTextureTransformExtension();
+							break;
+
+						case EXTENSIONS.KHR_MESH_QUANTIZATION:
+							extensions[ extensionName ] = new GLTFMeshQuantizationExtension();
+							break;
+
+						default:
+							if ( extensionsRequired.indexOf( extensionName ) >= 0 && plugins[ extensionName ] === undefined ) {
+
+								console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' );
+
+							}
+
+					}
+
+				}
+
+			}
+
+			parser.setExtensions( extensions );
+			parser.setPlugins( plugins );
+			parser.parse( onLoad, onError );
+
+		}
+
+	}
+	/* GLTFREGISTRY */
+
+
+	function GLTFRegistry() {
+
+		let objects = {};
+		return {
+			get: function ( key ) {
+
+				return objects[ key ];
+
+			},
+			add: function ( key, object ) {
+
+				objects[ key ] = object;
+
+			},
+			remove: function ( key ) {
+
+				delete objects[ key ];
+
+			},
+			removeAll: function () {
+
+				objects = {};
+
+			}
+		};
+
+	}
+	/*********************************/
+
+	/********** EXTENSIONS ***********/
+
+	/*********************************/
+
+
+	const EXTENSIONS = {
+		KHR_BINARY_GLTF: 'KHR_binary_glTF',
+		KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
+		KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
+		KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
+		KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
+		KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
+		KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
+		KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
+		KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
+		KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
+		EXT_TEXTURE_WEBP: 'EXT_texture_webp',
+		EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression'
+	};
+	/**
+	 * Punctual Lights Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
+	 */
+
+	class GLTFLightsExtension {
+
+		constructor( parser ) {
+
+			this.parser = parser;
+			this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL; // THREE.Object3D instance caches
+
+			this.cache = {
+				refs: {},
+				uses: {}
+			};
+
+		}
+
+		_markDefs() {
+
+			const parser = this.parser;
+			const nodeDefs = this.parser.json.nodes || [];
+
+			for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
+
+				const nodeDef = nodeDefs[ nodeIndex ];
+
+				if ( nodeDef.extensions && nodeDef.extensions[ this.name ] && nodeDef.extensions[ this.name ].light !== undefined ) {
+
+					parser._addNodeRef( this.cache, nodeDef.extensions[ this.name ].light );
+
+				}
+
+			}
+
+		}
+
+		_loadLight( lightIndex ) {
+
+			const parser = this.parser;
+			const cacheKey = 'light:' + lightIndex;
+			let dependency = parser.cache.get( cacheKey );
+			if ( dependency ) return dependency;
+			const json = parser.json;
+			const extensions = json.extensions && json.extensions[ this.name ] || {};
+			const lightDefs = extensions.lights || [];
+			const lightDef = lightDefs[ lightIndex ];
+			let lightNode;
+			const color = new THREE.Color( 0xffffff );
+			if ( lightDef.color !== undefined ) color.fromArray( lightDef.color );
+			const range = lightDef.range !== undefined ? lightDef.range : 0;
+
+			switch ( lightDef.type ) {
+
+				case 'directional':
+					lightNode = new THREE.DirectionalLight( color );
+					lightNode.target.position.set( 0, 0, - 1 );
+					lightNode.add( lightNode.target );
+					break;
+
+				case 'point':
+					lightNode = new THREE.PointLight( color );
+					lightNode.distance = range;
+					break;
+
+				case 'spot':
+					lightNode = new THREE.SpotLight( color );
+					lightNode.distance = range; // Handle spotlight properties.
+
+					lightDef.spot = lightDef.spot || {};
+					lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;
+					lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;
+					lightNode.angle = lightDef.spot.outerConeAngle;
+					lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
+					lightNode.target.position.set( 0, 0, - 1 );
+					lightNode.add( lightNode.target );
+					break;
+
+				default:
+					throw new Error( 'THREE.GLTFLoader: Unexpected light type: ' + lightDef.type );
+
+			} // Some lights (e.g. spot) default to a position other than the origin. Reset the position
+			// here, because node-level parsing will only override position if explicitly specified.
+
+
+			lightNode.position.set( 0, 0, 0 );
+			lightNode.decay = 2;
+			if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
+			lightNode.name = parser.createUniqueName( lightDef.name || 'light_' + lightIndex );
+			dependency = Promise.resolve( lightNode );
+			parser.cache.add( cacheKey, dependency );
+			return dependency;
+
+		}
+
+		createNodeAttachment( nodeIndex ) {
+
+			const self = this;
+			const parser = this.parser;
+			const json = parser.json;
+			const nodeDef = json.nodes[ nodeIndex ];
+			const lightDef = nodeDef.extensions && nodeDef.extensions[ this.name ] || {};
+			const lightIndex = lightDef.light;
+			if ( lightIndex === undefined ) return null;
+			return this._loadLight( lightIndex ).then( function ( light ) {
+
+				return parser._getNodeRef( self.cache, lightIndex, light );
+
+			} );
+
+		}
+
+	}
+	/**
+	 * Unlit Materials Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
+	 */
+
+
+	class GLTFMaterialsUnlitExtension {
+
+		constructor() {
+
+			this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
+
+		}
+
+		getMaterialType() {
+
+			return THREE.MeshBasicMaterial;
+
+		}
+
+		extendParams( materialParams, materialDef, parser ) {
+
+			const pending = [];
+			materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
+			materialParams.opacity = 1.0;
+			const metallicRoughness = materialDef.pbrMetallicRoughness;
+
+			if ( metallicRoughness ) {
+
+				if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
+
+					const array = metallicRoughness.baseColorFactor;
+					materialParams.color.fromArray( array );
+					materialParams.opacity = array[ 3 ];
+
+				}
+
+				if ( metallicRoughness.baseColorTexture !== undefined ) {
+
+					pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) );
+
+				}
+
+			}
+
+			return Promise.all( pending );
+
+		}
+
+	}
+	/**
+	 * Clearcoat Materials Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
+	 */
+
+
+	class GLTFMaterialsClearcoatExtension {
+
+		constructor( parser ) {
+
+			this.parser = parser;
+			this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
+
+		}
+
+		getMaterialType( materialIndex ) {
+
+			const parser = this.parser;
+			const materialDef = parser.json.materials[ materialIndex ];
+			if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
+			return THREE.MeshPhysicalMaterial;
+
+		}
+
+		extendMaterialParams( materialIndex, materialParams ) {
+
+			const parser = this.parser;
+			const materialDef = parser.json.materials[ materialIndex ];
+
+			if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
+
+				return Promise.resolve();
+
+			}
+
+			const pending = [];
+			const extension = materialDef.extensions[ this.name ];
+
+			if ( extension.clearcoatFactor !== undefined ) {
+
+				materialParams.clearcoat = extension.clearcoatFactor;
+
+			}
+
+			if ( extension.clearcoatTexture !== undefined ) {
+
+				pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
+
+			}
+
+			if ( extension.clearcoatRoughnessFactor !== undefined ) {
+
+				materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
+
+			}
+
+			if ( extension.clearcoatRoughnessTexture !== undefined ) {
+
+				pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
+
+			}
+
+			if ( extension.clearcoatNormalTexture !== undefined ) {
+
+				pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
+
+				if ( extension.clearcoatNormalTexture.scale !== undefined ) {
+
+					const scale = extension.clearcoatNormalTexture.scale; // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
+
+					materialParams.clearcoatNormalScale = new THREE.Vector2( scale, - scale );
+
+				}
+
+			}
+
+			return Promise.all( pending );
+
+		}
+
+	}
+	/**
+	 * Transmission Materials Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
+	 * Draft: https://github.com/KhronosGroup/glTF/pull/1698
+	 */
+
+
+	class GLTFMaterialsTransmissionExtension {
+
+		constructor( parser ) {
+
+			this.parser = parser;
+			this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
+
+		}
+
+		getMaterialType( materialIndex ) {
+
+			const parser = this.parser;
+			const materialDef = parser.json.materials[ materialIndex ];
+			if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
+			return THREE.MeshPhysicalMaterial;
+
+		}
+
+		extendMaterialParams( materialIndex, materialParams ) {
+
+			const parser = this.parser;
+			const materialDef = parser.json.materials[ materialIndex ];
+
+			if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
+
+				return Promise.resolve();
+
+			}
+
+			const pending = [];
+			const extension = materialDef.extensions[ this.name ];
+
+			if ( extension.transmissionFactor !== undefined ) {
+
+				materialParams.transmission = extension.transmissionFactor;
+
+			}
+
+			if ( extension.transmissionTexture !== undefined ) {
+
+				pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
+
+			}
+
+			return Promise.all( pending );
+
+		}
+
+	}
+	/**
+	 * BasisU Texture Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
+	 */
+
+
+	class GLTFTextureBasisUExtension {
+
+		constructor( parser ) {
+
+			this.parser = parser;
+			this.name = EXTENSIONS.KHR_TEXTURE_BASISU;
+
+		}
+
+		loadTexture( textureIndex ) {
+
+			const parser = this.parser;
+			const json = parser.json;
+			const textureDef = json.textures[ textureIndex ];
+
+			if ( ! textureDef.extensions || ! textureDef.extensions[ this.name ] ) {
+
+				return null;
+
+			}
+
+			const extension = textureDef.extensions[ this.name ];
+			const source = json.images[ extension.source ];
+			const loader = parser.options.ktx2Loader;
+
+			if ( ! loader ) {
+
+				if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
+
+					throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
+
+				} else {
+
+					// Assumes that the extension is optional and that a fallback texture is present
+					return null;
+
+				}
+
+			}
+
+			return parser.loadTextureImage( textureIndex, source, loader );
+
+		}
+
+	}
+	/**
+	 * WebP Texture Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
+	 */
+
+
+	class GLTFTextureWebPExtension {
+
+		constructor( parser ) {
+
+			this.parser = parser;
+			this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
+			this.isSupported = null;
+
+		}
+
+		loadTexture( textureIndex ) {
+
+			const name = this.name;
+			const parser = this.parser;
+			const json = parser.json;
+			const textureDef = json.textures[ textureIndex ];
+
+			if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
+
+				return null;
+
+			}
+
+			const extension = textureDef.extensions[ name ];
+			const source = json.images[ extension.source ];
+			let loader = parser.textureLoader;
+
+			if ( source.uri ) {
+
+				const handler = parser.options.manager.getHandler( source.uri );
+				if ( handler !== null ) loader = handler;
+
+			}
+
+			return this.detectSupport().then( function ( isSupported ) {
+
+				if ( isSupported ) return parser.loadTextureImage( textureIndex, source, loader );
+
+				if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
+
+					throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' );
+
+				} // Fall back to PNG or JPEG.
+
+
+				return parser.loadTexture( textureIndex );
+
+			} );
+
+		}
+
+		detectSupport() {
+
+			if ( ! this.isSupported ) {
+
+				this.isSupported = new Promise( function ( resolve ) {
+
+					const image = new Image(); // Lossy test image. Support for lossy images doesn't guarantee support for all
+					// WebP images, unfortunately.
+
+					image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
+
+					image.onload = image.onerror = function () {
+
+						resolve( image.height === 1 );
+
+					};
+
+				} );
+
+			}
+
+			return this.isSupported;
+
+		}
+
+	}
+	/**
+	* meshopt BufferView Compression Extension
+	*
+	* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
+	*/
+
+
+	class GLTFMeshoptCompression {
+
+		constructor( parser ) {
+
+			this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION;
+			this.parser = parser;
+
+		}
+
+		loadBufferView( index ) {
+
+			const json = this.parser.json;
+			const bufferView = json.bufferViews[ index ];
+
+			if ( bufferView.extensions && bufferView.extensions[ this.name ] ) {
+
+				const extensionDef = bufferView.extensions[ this.name ];
+				const buffer = this.parser.getDependency( 'buffer', extensionDef.buffer );
+				const decoder = this.parser.options.meshoptDecoder;
+
+				if ( ! decoder || ! decoder.supported ) {
+
+					if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
+
+						throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' );
+
+					} else {
+
+						// Assumes that the extension is optional and that fallback buffer data is present
+						return null;
+
+					}
+
+				}
+
+				return Promise.all( [ buffer, decoder.ready ] ).then( function ( res ) {
+
+					const byteOffset = extensionDef.byteOffset || 0;
+					const byteLength = extensionDef.byteLength || 0;
+					const count = extensionDef.count;
+					const stride = extensionDef.byteStride;
+					const result = new ArrayBuffer( count * stride );
+					const source = new Uint8Array( res[ 0 ], byteOffset, byteLength );
+					decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter );
+					return result;
+
+				} );
+
+			} else {
+
+				return null;
+
+			}
+
+		}
+
+	}
+	/* BINARY EXTENSION */
+
+
+	const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
+	const BINARY_EXTENSION_HEADER_LENGTH = 12;
+	const BINARY_EXTENSION_CHUNK_TYPES = {
+		JSON: 0x4E4F534A,
+		BIN: 0x004E4942
+	};
+
+	class GLTFBinaryExtension {
+
+		constructor( data ) {
+
+			this.name = EXTENSIONS.KHR_BINARY_GLTF;
+			this.content = null;
+			this.body = null;
+			const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
+			this.header = {
+				magic: THREE.LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ),
+				version: headerView.getUint32( 4, true ),
+				length: headerView.getUint32( 8, true )
+			};
+
+			if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) {
+
+				throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' );
+
+			} else if ( this.header.version < 2.0 ) {
+
+				throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
+
+			}
+
+			const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH;
+			const chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH );
+			let chunkIndex = 0;
+
+			while ( chunkIndex < chunkContentsLength ) {
+
+				const chunkLength = chunkView.getUint32( chunkIndex, true );
+				chunkIndex += 4;
+				const chunkType = chunkView.getUint32( chunkIndex, true );
+				chunkIndex += 4;
+
+				if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
+
+					const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
+					this.content = THREE.LoaderUtils.decodeText( contentArray );
+
+				} else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
+
+					const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
+					this.body = data.slice( byteOffset, byteOffset + chunkLength );
+
+				} // Clients must ignore chunks with unknown types.
+
+
+				chunkIndex += chunkLength;
+
+			}
+
+			if ( this.content === null ) {
+
+				throw new Error( 'THREE.GLTFLoader: JSON content not found.' );
+
+			}
+
+		}
+
+	}
+	/**
+	 * DRACO THREE.Mesh Compression Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
+	 */
+
+
+	class GLTFDracoMeshCompressionExtension {
+
+		constructor( json, dracoLoader ) {
+
+			if ( ! dracoLoader ) {
+
+				throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' );
+
+			}
+
+			this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
+			this.json = json;
+			this.dracoLoader = dracoLoader;
+			this.dracoLoader.preload();
+
+		}
+
+		decodePrimitive( primitive, parser ) {
+
+			const json = this.json;
+			const dracoLoader = this.dracoLoader;
+			const bufferViewIndex = primitive.extensions[ this.name ].bufferView;
+			const gltfAttributeMap = primitive.extensions[ this.name ].attributes;
+			const threeAttributeMap = {};
+			const attributeNormalizedMap = {};
+			const attributeTypeMap = {};
+
+			for ( const attributeName in gltfAttributeMap ) {
+
+				const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
+				threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ];
+
+			}
+
+			for ( const attributeName in primitive.attributes ) {
+
+				const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
+
+				if ( gltfAttributeMap[ attributeName ] !== undefined ) {
+
+					const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
+					const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
+					attributeTypeMap[ threeAttributeName ] = componentType;
+					attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
+
+				}
+
+			}
+
+			return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) {
+
+				return new Promise( function ( resolve ) {
+
+					dracoLoader.decodeDracoFile( bufferView, function ( geometry ) {
+
+						for ( const attributeName in geometry.attributes ) {
+
+							const attribute = geometry.attributes[ attributeName ];
+							const normalized = attributeNormalizedMap[ attributeName ];
+							if ( normalized !== undefined ) attribute.normalized = normalized;
+
+						}
+
+						resolve( geometry );
+
+					}, threeAttributeMap, attributeTypeMap );
+
+				} );
+
+			} );
+
+		}
+
+	}
+	/**
+	 * Texture Transform Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
+	 */
+
+
+	class GLTFTextureTransformExtension {
+
+		constructor() {
+
+			this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
+
+		}
+
+		extendTexture( texture, transform ) {
+
+			texture = texture.clone();
+
+			if ( transform.offset !== undefined ) {
+
+				texture.offset.fromArray( transform.offset );
+
+			}
+
+			if ( transform.rotation !== undefined ) {
+
+				texture.rotation = transform.rotation;
+
+			}
+
+			if ( transform.scale !== undefined ) {
+
+				texture.repeat.fromArray( transform.scale );
+
+			}
+
+			if ( transform.texCoord !== undefined ) {
+
+				console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
+
+			}
+
+			texture.needsUpdate = true;
+			return texture;
+
+		}
+
+	}
+	/**
+	 * Specular-Glossiness Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
+	 */
+
+	/**
+	 * A sub class of StandardMaterial with some of the functionality
+	 * changed via the `onBeforeCompile` callback
+	 * @pailhead
+	 */
+
+
+	class GLTFMeshStandardSGMaterial extends THREE.MeshStandardMaterial {
+
+		constructor( params ) {
+
+			super();
+			this.isGLTFSpecularGlossinessMaterial = true; //various chunks that need replacing
+
+			const specularMapParsFragmentChunk = [ '#ifdef USE_SPECULARMAP', '	uniform sampler2D specularMap;', '#endif' ].join( '\n' );
+			const glossinessMapParsFragmentChunk = [ '#ifdef USE_GLOSSINESSMAP', '	uniform sampler2D glossinessMap;', '#endif' ].join( '\n' );
+			const specularMapFragmentChunk = [ 'vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', '	vec4 texelSpecular = texture2D( specularMap, vUv );', '	texelSpecular = sRGBToLinear( texelSpecular );', '	// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', '	specularFactor *= texelSpecular.rgb;', '#endif' ].join( '\n' );
+			const glossinessMapFragmentChunk = [ 'float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', '	vec4 texelGlossiness = texture2D( glossinessMap, vUv );', '	// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', '	glossinessFactor *= texelGlossiness.a;', '#endif' ].join( '\n' );
+			const lightPhysicalFragmentChunk = [ 'PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', 'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', 'material.specularRoughness += geometryRoughness;', 'material.specularRoughness = min( material.specularRoughness, 1.0 );', 'material.specularColor = specularFactor;' ].join( '\n' );
+			const uniforms = {
+				specular: {
+					value: new THREE.Color().setHex( 0xffffff )
+				},
+				glossiness: {
+					value: 1
+				},
+				specularMap: {
+					value: null
+				},
+				glossinessMap: {
+					value: null
+				}
+			};
+			this._extraUniforms = uniforms;
+
+			this.onBeforeCompile = function ( shader ) {
+
+				for ( const uniformName in uniforms ) {
+
+					shader.uniforms[ uniformName ] = uniforms[ uniformName ];
+
+				}
+
+				shader.fragmentShader = shader.fragmentShader.replace( 'uniform float roughness;', 'uniform vec3 specular;' ).replace( 'uniform float metalness;', 'uniform float glossiness;' ).replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk ).replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk ).replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk ).replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk ).replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
+
+			};
+
+			Object.defineProperties( this, {
+				specular: {
+					get: function () {
+
+						return uniforms.specular.value;
+
+					},
+					set: function ( v ) {
+
+						uniforms.specular.value = v;
+
+					}
+				},
+				specularMap: {
+					get: function () {
+
+						return uniforms.specularMap.value;
+
+					},
+					set: function ( v ) {
+
+						uniforms.specularMap.value = v;
+
+						if ( v ) {
+
+							this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps
+
+						} else {
+
+							delete this.defines.USE_SPECULARMAP;
+
+						}
+
+					}
+				},
+				glossiness: {
+					get: function () {
+
+						return uniforms.glossiness.value;
+
+					},
+					set: function ( v ) {
+
+						uniforms.glossiness.value = v;
+
+					}
+				},
+				glossinessMap: {
+					get: function () {
+
+						return uniforms.glossinessMap.value;
+
+					},
+					set: function ( v ) {
+
+						uniforms.glossinessMap.value = v;
+
+						if ( v ) {
+
+							this.defines.USE_GLOSSINESSMAP = '';
+							this.defines.USE_UV = '';
+
+						} else {
+
+							delete this.defines.USE_GLOSSINESSMAP;
+							delete this.defines.USE_UV;
+
+						}
+
+					}
+				}
+			} );
+			delete this.metalness;
+			delete this.roughness;
+			delete this.metalnessMap;
+			delete this.roughnessMap;
+			this.setValues( params );
+
+		}
+
+		copy( source ) {
+
+			super.copy( source );
+			this.specularMap = source.specularMap;
+			this.specular.copy( source.specular );
+			this.glossinessMap = source.glossinessMap;
+			this.glossiness = source.glossiness;
+			delete this.metalness;
+			delete this.roughness;
+			delete this.metalnessMap;
+			delete this.roughnessMap;
+			return this;
+
+		}
+
+	}
+
+	class GLTFMaterialsPbrSpecularGlossinessExtension {
+
+		constructor() {
+
+			this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS;
+			this.specularGlossinessParams = [ 'color', 'map', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveIntensity', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'normalMapType', 'displacementMap', 'displacementScale', 'displacementBias', 'specularMap', 'specular', 'glossinessMap', 'glossiness', 'alphaMap', 'envMap', 'envMapIntensity', 'refractionRatio' ];
+
+		}
+
+		getMaterialType() {
+
+			return GLTFMeshStandardSGMaterial;
+
+		}
+
+		extendParams( materialParams, materialDef, parser ) {
+
+			const pbrSpecularGlossiness = materialDef.extensions[ this.name ];
+			materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
+			materialParams.opacity = 1.0;
+			const pending = [];
+
+			if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) {
+
+				const array = pbrSpecularGlossiness.diffuseFactor;
+				materialParams.color.fromArray( array );
+				materialParams.opacity = array[ 3 ];
+
+			}
+
+			if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
+
+				pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture ) );
+
+			}
+
+			materialParams.emissive = new THREE.Color( 0.0, 0.0, 0.0 );
+			materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
+			materialParams.specular = new THREE.Color( 1.0, 1.0, 1.0 );
+
+			if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
+
+				materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor );
+
+			}
+
+			if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
+
+				const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
+				pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) );
+				pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef ) );
+
+			}
+
+			return Promise.all( pending );
+
+		}
+
+		createMaterial( materialParams ) {
+
+			const material = new GLTFMeshStandardSGMaterial( materialParams );
+			material.fog = true;
+			material.color = materialParams.color;
+			material.map = materialParams.map === undefined ? null : materialParams.map;
+			material.lightMap = null;
+			material.lightMapIntensity = 1.0;
+			material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;
+			material.aoMapIntensity = 1.0;
+			material.emissive = materialParams.emissive;
+			material.emissiveIntensity = 1.0;
+			material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;
+			material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;
+			material.bumpScale = 1;
+			material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap;
+			material.normalMapType = THREE.TangentSpaceNormalMap;
+			if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale;
+			material.displacementMap = null;
+			material.displacementScale = 1;
+			material.displacementBias = 0;
+			material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap;
+			material.specular = materialParams.specular;
+			material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;
+			material.glossiness = materialParams.glossiness;
+			material.alphaMap = null;
+			material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;
+			material.envMapIntensity = 1.0;
+			material.refractionRatio = 0.98;
+			return material;
+
+		}
+
+	}
+	/**
+	 * THREE.Mesh Quantization Extension
+	 *
+	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
+	 */
+
+
+	class GLTFMeshQuantizationExtension {
+
+		constructor() {
+
+			this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
+
+		}
+
+	}
+	/*********************************/
+
+	/********** INTERPOLATION ********/
+
+	/*********************************/
+	// Spline Interpolation
+	// Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
+
+
+	class GLTFCubicSplineInterpolant extends THREE.Interpolant {
+
+		constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
+
+			super( parameterPositions, sampleValues, sampleSize, resultBuffer );
+
+		}
+
+		copySampleValue_( index ) {
+
+			// Copies a sample value to the result buffer. See description of glTF
+			// CUBICSPLINE values layout in interpolate_() function below.
+			const result = this.resultBuffer,
+				values = this.sampleValues,
+				valueSize = this.valueSize,
+				offset = index * valueSize * 3 + valueSize;
+
+			for ( let i = 0; i !== valueSize; i ++ ) {
+
+				result[ i ] = values[ offset + i ];
+
+			}
+
+			return result;
+
+		}
+
+	}
+
+	GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
+	GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
+
+	GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) {
+
+		const result = this.resultBuffer;
+		const values = this.sampleValues;
+		const stride = this.valueSize;
+		const stride2 = stride * 2;
+		const stride3 = stride * 3;
+		const td = t1 - t0;
+		const p = ( t - t0 ) / td;
+		const pp = p * p;
+		const ppp = pp * p;
+		const offset1 = i1 * stride3;
+		const offset0 = offset1 - stride3;
+		const s2 = - 2 * ppp + 3 * pp;
+		const s3 = ppp - pp;
+		const s0 = 1 - s2;
+		const s1 = s3 - pp + p; // Layout of keyframe output values for CUBICSPLINE animations:
+		//   [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
+
+		for ( let i = 0; i !== stride; i ++ ) {
+
+			const p0 = values[ offset0 + i + stride ]; // splineVertex_k
+
+			const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
+
+			const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
+
+			const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
+
+			result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
+
+		}
+
+		return result;
+
+	};
+	/*********************************/
+
+	/********** INTERNALS ************/
+
+	/*********************************/
+
+	/* CONSTANTS */
+
+
+	const WEBGL_CONSTANTS = {
+		FLOAT: 5126,
+		//FLOAT_MAT2: 35674,
+		FLOAT_MAT3: 35675,
+		FLOAT_MAT4: 35676,
+		FLOAT_VEC2: 35664,
+		FLOAT_VEC3: 35665,
+		FLOAT_VEC4: 35666,
+		LINEAR: 9729,
+		REPEAT: 10497,
+		SAMPLER_2D: 35678,
+		POINTS: 0,
+		LINES: 1,
+		LINE_LOOP: 2,
+		LINE_STRIP: 3,
+		TRIANGLES: 4,
+		TRIANGLE_STRIP: 5,
+		TRIANGLE_FAN: 6,
+		UNSIGNED_BYTE: 5121,
+		UNSIGNED_SHORT: 5123
+	};
+	const WEBGL_COMPONENT_TYPES = {
+		5120: Int8Array,
+		5121: Uint8Array,
+		5122: Int16Array,
+		5123: Uint16Array,
+		5125: Uint32Array,
+		5126: Float32Array
+	};
+	const WEBGL_FILTERS = {
+		9728: THREE.NearestFilter,
+		9729: THREE.LinearFilter,
+		9984: THREE.NearestMipmapNearestFilter,
+		9985: THREE.LinearMipmapNearestFilter,
+		9986: THREE.NearestMipmapLinearFilter,
+		9987: THREE.LinearMipmapLinearFilter
+	};
+	const WEBGL_WRAPPINGS = {
+		33071: THREE.ClampToEdgeWrapping,
+		33648: THREE.MirroredRepeatWrapping,
+		10497: THREE.RepeatWrapping
+	};
+	const WEBGL_TYPE_SIZES = {
+		'SCALAR': 1,
+		'VEC2': 2,
+		'VEC3': 3,
+		'VEC4': 4,
+		'MAT2': 4,
+		'MAT3': 9,
+		'MAT4': 16
+	};
+	const ATTRIBUTES = {
+		POSITION: 'position',
+		NORMAL: 'normal',
+		TANGENT: 'tangent',
+		TEXCOORD_0: 'uv',
+		TEXCOORD_1: 'uv2',
+		COLOR_0: 'color',
+		WEIGHTS_0: 'skinWeight',
+		JOINTS_0: 'skinIndex'
+	};
+	const PATH_PROPERTIES = {
+		scale: 'scale',
+		translation: 'position',
+		rotation: 'quaternion',
+		weights: 'morphTargetInfluences'
+	};
+	const INTERPOLATION = {
+		CUBICSPLINE: undefined,
+		// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
+		// keyframe track will be initialized with a default interpolation type, then modified.
+		LINEAR: THREE.InterpolateLinear,
+		STEP: THREE.InterpolateDiscrete
+	};
+	const ALPHA_MODES = {
+		OPAQUE: 'OPAQUE',
+		MASK: 'MASK',
+		BLEND: 'BLEND'
+	};
+	/* UTILITY FUNCTIONS */
+
+	function resolveURL( url, path ) {
+
+		// Invalid URL
+		if ( typeof url !== 'string' || url === '' ) return ''; // Host Relative URL
+
+		if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) {
+
+			path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' );
+
+		} // Absolute URL http://,https://,//
+
+
+		if ( /^(https?:)?\/\//i.test( url ) ) return url; // Data URI
+
+		if ( /^data:.*,.*$/i.test( url ) ) return url; // Blob URL
+
+		if ( /^blob:.*$/i.test( url ) ) return url; // Relative URL
+
+		return path + url;
+
+	}
+	/**
+	 * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
+	 */
+
+
+	function createDefaultMaterial( cache ) {
+
+		if ( cache[ 'DefaultMaterial' ] === undefined ) {
+
+			cache[ 'DefaultMaterial' ] = new THREE.MeshStandardMaterial( {
+				color: 0xFFFFFF,
+				emissive: 0x000000,
+				metalness: 1,
+				roughness: 1,
+				transparent: false,
+				depthTest: true,
+				side: THREE.FrontSide
+			} );
+
+		}
+
+		return cache[ 'DefaultMaterial' ];
+
+	}
+
+	function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
+
+		// Add unknown glTF extensions to an object's userData.
+		for ( const name in objectDef.extensions ) {
+
+			if ( knownExtensions[ name ] === undefined ) {
+
+				object.userData.gltfExtensions = object.userData.gltfExtensions || {};
+				object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ];
+
+			}
+
+		}
+
+	}
+	/**
+	 * @param {Object3D|Material|BufferGeometry} object
+	 * @param {GLTF.definition} gltfDef
+	 */
+
+
+	function assignExtrasToUserData( object, gltfDef ) {
+
+		if ( gltfDef.extras !== undefined ) {
+
+			if ( typeof gltfDef.extras === 'object' ) {
+
+				Object.assign( object.userData, gltfDef.extras );
+
+			} else {
+
+				console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras );
+
+			}
+
+		}
+
+	}
+	/**
+	 * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
+	 *
+	 * @param {BufferGeometry} geometry
+	 * @param {Array<GLTF.Target>} targets
+	 * @param {GLTFParser} parser
+	 * @return {Promise<BufferGeometry>}
+	 */
+
+
+	function addMorphTargets( geometry, targets, parser ) {
+
+		let hasMorphPosition = false;
+		let hasMorphNormal = false;
+
+		for ( let i = 0, il = targets.length; i < il; i ++ ) {
+
+			const target = targets[ i ];
+			if ( target.POSITION !== undefined ) hasMorphPosition = true;
+			if ( target.NORMAL !== undefined ) hasMorphNormal = true;
+			if ( hasMorphPosition && hasMorphNormal ) break;
+
+		}
+
+		if ( ! hasMorphPosition && ! hasMorphNormal ) return Promise.resolve( geometry );
+		const pendingPositionAccessors = [];
+		const pendingNormalAccessors = [];
+
+		for ( let i = 0, il = targets.length; i < il; i ++ ) {
+
+			const target = targets[ i ];
+
+			if ( hasMorphPosition ) {
+
+				const pendingAccessor = target.POSITION !== undefined ? parser.getDependency( 'accessor', target.POSITION ) : geometry.attributes.position;
+				pendingPositionAccessors.push( pendingAccessor );
+
+			}
+
+			if ( hasMorphNormal ) {
+
+				const pendingAccessor = target.NORMAL !== undefined ? parser.getDependency( 'accessor', target.NORMAL ) : geometry.attributes.normal;
+				pendingNormalAccessors.push( pendingAccessor );
+
+			}
+
+		}
+
+		return Promise.all( [ Promise.all( pendingPositionAccessors ), Promise.all( pendingNormalAccessors ) ] ).then( function ( accessors ) {
+
+			const morphPositions = accessors[ 0 ];
+			const morphNormals = accessors[ 1 ];
+			if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
+			if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;
+			geometry.morphTargetsRelative = true;
+			return geometry;
+
+		} );
+
+	}
+	/**
+	 * @param {Mesh} mesh
+	 * @param {GLTF.Mesh} meshDef
+	 */
+
+
+	function updateMorphTargets( mesh, meshDef ) {
+
+		mesh.updateMorphTargets();
+
+		if ( meshDef.weights !== undefined ) {
+
+			for ( let i = 0, il = meshDef.weights.length; i < il; i ++ ) {
+
+				mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ];
+
+			}
+
+		} // .extras has user-defined data, so check that .extras.targetNames is an array.
+
+
+		if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
+
+			const targetNames = meshDef.extras.targetNames;
+
+			if ( mesh.morphTargetInfluences.length === targetNames.length ) {
+
+				mesh.morphTargetDictionary = {};
+
+				for ( let i = 0, il = targetNames.length; i < il; i ++ ) {
+
+					mesh.morphTargetDictionary[ targetNames[ i ] ] = i;
+
+				}
+
+			} else {
+
+				console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' );
+
+			}
+
+		}
+
+	}
+
+	function createPrimitiveKey( primitiveDef ) {
+
+		const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
+		let geometryKey;
+
+		if ( dracoExtension ) {
+
+			geometryKey = 'draco:' + dracoExtension.bufferView + ':' + dracoExtension.indices + ':' + createAttributesKey( dracoExtension.attributes );
+
+		} else {
+
+			geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
+
+		}
+
+		return geometryKey;
+
+	}
+
+	function createAttributesKey( attributes ) {
+
+		let attributesKey = '';
+		const keys = Object.keys( attributes ).sort();
+
+		for ( let i = 0, il = keys.length; i < il; i ++ ) {
+
+			attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';';
+
+		}
+
+		return attributesKey;
+
+	}
+
+	function getNormalizedComponentScale( constructor ) {
+
+		// Reference:
+		// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
+		switch ( constructor ) {
+
+			case Int8Array:
+				return 1 / 127;
+
+			case Uint8Array:
+				return 1 / 255;
+
+			case Int16Array:
+				return 1 / 32767;
+
+			case Uint16Array:
+				return 1 / 65535;
+
+			default:
+				throw new Error( 'THREE.GLTFLoader: Unsupported normalized accessor component type.' );
+
+		}
+
+	}
+	/* GLTF PARSER */
+
+
+	class GLTFParser {
+
+		constructor( json = {}, options = {} ) {
+
+			this.json = json;
+			this.extensions = {};
+			this.plugins = {};
+			this.options = options; // loader object cache
+
+			this.cache = new GLTFRegistry(); // associations between Three.js objects and glTF elements
+
+			this.associations = new Map(); // THREE.BufferGeometry caching
+
+			this.primitiveCache = {}; // THREE.Object3D instance caches
+
+			this.meshCache = {
+				refs: {},
+				uses: {}
+			};
+			this.cameraCache = {
+				refs: {},
+				uses: {}
+			};
+			this.lightCache = {
+				refs: {},
+				uses: {}
+			}; // Track node names, to ensure no duplicates
+
+			this.nodeNamesUsed = {}; // Use an THREE.ImageBitmapLoader if imageBitmaps are supported. Moves much of the
+			// expensive work of uploading a texture to the GPU off the main thread.
+
+			if ( typeof createImageBitmap !== 'undefined' && /Firefox/.test( navigator.userAgent ) === false ) {
+
+				this.textureLoader = new THREE.ImageBitmapLoader( this.options.manager );
+
+			} else {
+
+				this.textureLoader = new THREE.TextureLoader( this.options.manager );
+
+			}
+
+			this.textureLoader.setCrossOrigin( this.options.crossOrigin );
+			this.textureLoader.setRequestHeader( this.options.requestHeader );
+			this.fileLoader = new THREE.FileLoader( this.options.manager );
+			this.fileLoader.setResponseType( 'arraybuffer' );
+
+			if ( this.options.crossOrigin === 'use-credentials' ) {
+
+				this.fileLoader.setWithCredentials( true );
+
+			}
+
+		}
+
+		setExtensions( extensions ) {
+
+			this.extensions = extensions;
+
+		}
+
+		setPlugins( plugins ) {
+
+			this.plugins = plugins;
+
+		}
+
+		parse( onLoad, onError ) {
+
+			const parser = this;
+			const json = this.json;
+			const extensions = this.extensions; // Clear the loader cache
+
+			this.cache.removeAll(); // Mark the special nodes/meshes in json for efficient parse
+
+			this._invokeAll( function ( ext ) {
+
+				return ext._markDefs && ext._markDefs();
+
+			} );
+
+			Promise.all( this._invokeAll( function ( ext ) {
+
+				return ext.beforeRoot && ext.beforeRoot();
+
+			} ) ).then( function () {
+
+				return Promise.all( [ parser.getDependencies( 'scene' ), parser.getDependencies( 'animation' ), parser.getDependencies( 'camera' ) ] );
+
+			} ).then( function ( dependencies ) {
+
+				const result = {
+					scene: dependencies[ 0 ][ json.scene || 0 ],
+					scenes: dependencies[ 0 ],
+					animations: dependencies[ 1 ],
+					cameras: dependencies[ 2 ],
+					asset: json.asset,
+					parser: parser,
+					userData: {}
+				};
+				addUnknownExtensionsToUserData( extensions, result, json );
+				assignExtrasToUserData( result, json );
+				Promise.all( parser._invokeAll( function ( ext ) {
+
+					return ext.afterRoot && ext.afterRoot( result );
+
+				} ) ).then( function () {
+
+					onLoad( result );
+
+				} );
+
+			} ).catch( onError );
+
+		}
+		/**
+   * Marks the special nodes/meshes in json for efficient parse.
+   */
+
+
+		_markDefs() {
+
+			const nodeDefs = this.json.nodes || [];
+			const skinDefs = this.json.skins || [];
+			const meshDefs = this.json.meshes || []; // Nothing in the node definition indicates whether it is a THREE.Bone or an
+			// THREE.Object3D. Use the skins' joint references to mark bones.
+
+			for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) {
+
+				const joints = skinDefs[ skinIndex ].joints;
+
+				for ( let i = 0, il = joints.length; i < il; i ++ ) {
+
+					nodeDefs[ joints[ i ] ].isBone = true;
+
+				}
+
+			} // Iterate over all nodes, marking references to shared resources,
+			// as well as skeleton joints.
+
+
+			for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
+
+				const nodeDef = nodeDefs[ nodeIndex ];
+
+				if ( nodeDef.mesh !== undefined ) {
+
+					this._addNodeRef( this.meshCache, nodeDef.mesh ); // Nothing in the mesh definition indicates whether it is
+					// a THREE.SkinnedMesh or THREE.Mesh. Use the node's mesh reference
+					// to mark THREE.SkinnedMesh if node has skin.
+
+
+					if ( nodeDef.skin !== undefined ) {
+
+						meshDefs[ nodeDef.mesh ].isSkinnedMesh = true;
+
+					}
+
+				}
+
+				if ( nodeDef.camera !== undefined ) {
+
+					this._addNodeRef( this.cameraCache, nodeDef.camera );
+
+				}
+
+			}
+
+		}
+		/**
+   * Counts references to shared node / THREE.Object3D resources. These resources
+   * can be reused, or "instantiated", at multiple nodes in the scene
+   * hierarchy. THREE.Mesh, Camera, and Light instances are instantiated and must
+   * be marked. Non-scenegraph resources (like Materials, Geometries, and
+   * Textures) can be reused directly and are not marked here.
+   *
+   * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
+   */
+
+
+		_addNodeRef( cache, index ) {
+
+			if ( index === undefined ) return;
+
+			if ( cache.refs[ index ] === undefined ) {
+
+				cache.refs[ index ] = cache.uses[ index ] = 0;
+
+			}
+
+			cache.refs[ index ] ++;
+
+		}
+		/** Returns a reference to a shared resource, cloning it if necessary. */
+
+
+		_getNodeRef( cache, index, object ) {
+
+			if ( cache.refs[ index ] <= 1 ) return object;
+			const ref = object.clone();
+			ref.name += '_instance_' + cache.uses[ index ] ++;
+			return ref;
+
+		}
+
+		_invokeOne( func ) {
+
+			const extensions = Object.values( this.plugins );
+			extensions.push( this );
+
+			for ( let i = 0; i < extensions.length; i ++ ) {
+
+				const result = func( extensions[ i ] );
+				if ( result ) return result;
+
+			}
+
+			return null;
+
+		}
+
+		_invokeAll( func ) {
+
+			const extensions = Object.values( this.plugins );
+			extensions.unshift( this );
+			const pending = [];
+
+			for ( let i = 0; i < extensions.length; i ++ ) {
+
+				const result = func( extensions[ i ] );
+				if ( result ) pending.push( result );
+
+			}
+
+			return pending;
+
+		}
+		/**
+   * Requests the specified dependency asynchronously, with caching.
+   * @param {string} type
+   * @param {number} index
+   * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
+   */
+
+
+		getDependency( type, index ) {
+
+			const cacheKey = type + ':' + index;
+			let dependency = this.cache.get( cacheKey );
+
+			if ( ! dependency ) {
+
+				switch ( type ) {
+
+					case 'scene':
+						dependency = this.loadScene( index );
+						break;
+
+					case 'node':
+						dependency = this.loadNode( index );
+						break;
+
+					case 'mesh':
+						dependency = this._invokeOne( function ( ext ) {
+
+							return ext.loadMesh && ext.loadMesh( index );
+
+						} );
+						break;
+
+					case 'accessor':
+						dependency = this.loadAccessor( index );
+						break;
+
+					case 'bufferView':
+						dependency = this._invokeOne( function ( ext ) {
+
+							return ext.loadBufferView && ext.loadBufferView( index );
+
+						} );
+						break;
+
+					case 'buffer':
+						dependency = this.loadBuffer( index );
+						break;
+
+					case 'material':
+						dependency = this._invokeOne( function ( ext ) {
+
+							return ext.loadMaterial && ext.loadMaterial( index );
+
+						} );
+						break;
+
+					case 'texture':
+						dependency = this._invokeOne( function ( ext ) {
+
+							return ext.loadTexture && ext.loadTexture( index );
+
+						} );
+						break;
+
+					case 'skin':
+						dependency = this.loadSkin( index );
+						break;
+
+					case 'animation':
+						dependency = this.loadAnimation( index );
+						break;
+
+					case 'camera':
+						dependency = this.loadCamera( index );
+						break;
+
+					default:
+						throw new Error( 'Unknown type: ' + type );
+
+				}
+
+				this.cache.add( cacheKey, dependency );
+
+			}
+
+			return dependency;
+
+		}
+		/**
+   * Requests all dependencies of the specified type asynchronously, with caching.
+   * @param {string} type
+   * @return {Promise<Array<Object>>}
+   */
+
+
+		getDependencies( type ) {
+
+			let dependencies = this.cache.get( type );
+
+			if ( ! dependencies ) {
+
+				const parser = this;
+				const defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || [];
+				dependencies = Promise.all( defs.map( function ( def, index ) {
+
+					return parser.getDependency( type, index );
+
+				} ) );
+				this.cache.add( type, dependencies );
+
+			}
+
+			return dependencies;
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
+   * @param {number} bufferIndex
+   * @return {Promise<ArrayBuffer>}
+   */
+
+
+		loadBuffer( bufferIndex ) {
+
+			const bufferDef = this.json.buffers[ bufferIndex ];
+			const loader = this.fileLoader;
+
+			if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) {
+
+				throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' );
+
+			} // If present, GLB container is required to be the first buffer.
+
+
+			if ( bufferDef.uri === undefined && bufferIndex === 0 ) {
+
+				return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body );
+
+			}
+
+			const options = this.options;
+			return new Promise( function ( resolve, reject ) {
+
+				loader.load( resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () {
+
+					reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) );
+
+				} );
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
+   * @param {number} bufferViewIndex
+   * @return {Promise<ArrayBuffer>}
+   */
+
+
+		loadBufferView( bufferViewIndex ) {
+
+			const bufferViewDef = this.json.bufferViews[ bufferViewIndex ];
+			return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) {
+
+				const byteLength = bufferViewDef.byteLength || 0;
+				const byteOffset = bufferViewDef.byteOffset || 0;
+				return buffer.slice( byteOffset, byteOffset + byteLength );
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
+   * @param {number} accessorIndex
+   * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
+   */
+
+
+		loadAccessor( accessorIndex ) {
+
+			const parser = this;
+			const json = this.json;
+			const accessorDef = this.json.accessors[ accessorIndex ];
+
+			if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
+
+				// Ignore empty accessors, which may be used to declare runtime
+				// information about attributes coming from another source (e.g. Draco
+				// compression extension).
+				return Promise.resolve( null );
+
+			}
+
+			const pendingBufferViews = [];
+
+			if ( accessorDef.bufferView !== undefined ) {
+
+				pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) );
+
+			} else {
+
+				pendingBufferViews.push( null );
+
+			}
+
+			if ( accessorDef.sparse !== undefined ) {
+
+				pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) );
+				pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) );
+
+			}
+
+			return Promise.all( pendingBufferViews ).then( function ( bufferViews ) {
+
+				const bufferView = bufferViews[ 0 ];
+				const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
+				const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
+
+				const elementBytes = TypedArray.BYTES_PER_ELEMENT;
+				const itemBytes = elementBytes * itemSize;
+				const byteOffset = accessorDef.byteOffset || 0;
+				const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined;
+				const normalized = accessorDef.normalized === true;
+				let array, bufferAttribute; // The buffer is not interleaved if the stride is the item size in bytes.
+
+				if ( byteStride && byteStride !== itemBytes ) {
+
+					// Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own THREE.InterleavedBuffer
+					// This makes sure that IBA.count reflects accessor.count properly
+					const ibSlice = Math.floor( byteOffset / byteStride );
+					const ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
+					let ib = parser.cache.get( ibCacheKey );
+
+					if ( ! ib ) {
+
+						array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes ); // Integer parameters to IB/IBA are in array elements, not bytes.
+
+						ib = new THREE.InterleavedBuffer( array, byteStride / elementBytes );
+						parser.cache.add( ibCacheKey, ib );
+
+					}
+
+					bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, byteOffset % byteStride / elementBytes, normalized );
+
+				} else {
+
+					if ( bufferView === null ) {
+
+						array = new TypedArray( accessorDef.count * itemSize );
+
+					} else {
+
+						array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize );
+
+					}
+
+					bufferAttribute = new THREE.BufferAttribute( array, itemSize, normalized );
+
+				} // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
+
+
+				if ( accessorDef.sparse !== undefined ) {
+
+					const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
+					const TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ];
+					const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
+					const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
+					const sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices );
+					const sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize );
+
+					if ( bufferView !== null ) {
+
+						// Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
+						bufferAttribute = new THREE.BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized );
+
+					}
+
+					for ( let i = 0, il = sparseIndices.length; i < il; i ++ ) {
+
+						const index = sparseIndices[ i ];
+						bufferAttribute.setX( index, sparseValues[ i * itemSize ] );
+						if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] );
+						if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] );
+						if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] );
+						if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.' );
+
+					}
+
+				}
+
+				return bufferAttribute;
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
+   * @param {number} textureIndex
+   * @return {Promise<THREE.Texture>}
+   */
+
+
+		loadTexture( textureIndex ) {
+
+			const json = this.json;
+			const options = this.options;
+			const textureDef = json.textures[ textureIndex ];
+			const source = json.images[ textureDef.source ];
+			let loader = this.textureLoader;
+
+			if ( source.uri ) {
+
+				const handler = options.manager.getHandler( source.uri );
+				if ( handler !== null ) loader = handler;
+
+			}
+
+			return this.loadTextureImage( textureIndex, source, loader );
+
+		}
+
+		loadTextureImage( textureIndex, source, loader ) {
+
+			const parser = this;
+			const json = this.json;
+			const options = this.options;
+			const textureDef = json.textures[ textureIndex ];
+			const URL = self.URL || self.webkitURL;
+			let sourceURI = source.uri;
+			let isObjectURL = false;
+			let hasAlpha = true;
+			if ( source.mimeType === 'image/jpeg' ) hasAlpha = false;
+
+			if ( source.bufferView !== undefined ) {
+
+				// Load binary image data from bufferView, if provided.
+				sourceURI = parser.getDependency( 'bufferView', source.bufferView ).then( function ( bufferView ) {
+
+					if ( source.mimeType === 'image/png' ) {
+
+						// Inspect the PNG 'IHDR' chunk to determine whether the image could have an
+						// alpha channel. This check is conservative — the image could have an alpha
+						// channel with all values == 1, and the indexed type (colorType == 3) only
+						// sometimes contains alpha.
+						//
+						// https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header
+						const colorType = new DataView( bufferView, 25, 1 ).getUint8( 0, false );
+						hasAlpha = colorType === 6 || colorType === 4 || colorType === 3;
+
+					}
+
+					isObjectURL = true;
+					const blob = new Blob( [ bufferView ], {
+						type: source.mimeType
+					} );
+					sourceURI = URL.createObjectURL( blob );
+					return sourceURI;
+
+				} );
+
+			} else if ( source.uri === undefined ) {
+
+				throw new Error( 'THREE.GLTFLoader: Image ' + textureIndex + ' is missing URI and bufferView' );
+
+			}
+
+			return Promise.resolve( sourceURI ).then( function ( sourceURI ) {
+
+				return new Promise( function ( resolve, reject ) {
+
+					let onLoad = resolve;
+
+					if ( loader.isImageBitmapLoader === true ) {
+
+						onLoad = function ( imageBitmap ) {
+
+							resolve( new THREE.CanvasTexture( imageBitmap ) );
+
+						};
+
+					}
+
+					loader.load( resolveURL( sourceURI, options.path ), onLoad, undefined, reject );
+
+				} );
+
+			} ).then( function ( texture ) {
+
+				// Clean up resources and configure Texture.
+				if ( isObjectURL === true ) {
+
+					URL.revokeObjectURL( sourceURI );
+
+				}
+
+				texture.flipY = false;
+				if ( textureDef.name ) texture.name = textureDef.name; // When there is definitely no alpha channel in the texture, set THREE.RGBFormat to save space.
+
+				if ( ! hasAlpha ) texture.format = THREE.RGBFormat;
+				const samplers = json.samplers || {};
+				const sampler = samplers[ textureDef.sampler ] || {};
+				texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter;
+				texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.LinearMipmapLinearFilter;
+				texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping;
+				texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping;
+				parser.associations.set( texture, {
+					type: 'textures',
+					index: textureIndex
+				} );
+				return texture;
+
+			} );
+
+		}
+		/**
+   * Asynchronously assigns a texture to the given material parameters.
+   * @param {Object} materialParams
+   * @param {string} mapName
+   * @param {Object} mapDef
+   * @return {Promise}
+   */
+
+
+		assignTexture( materialParams, mapName, mapDef ) {
+
+			const parser = this;
+			return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
+
+				// Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
+				// However, we will copy UV set 0 to UV set 1 on demand for aoMap
+				if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
+
+					console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' );
+
+				}
+
+				if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) {
+
+					const transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined;
+
+					if ( transform ) {
+
+						const gltfReference = parser.associations.get( texture );
+						texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform );
+						parser.associations.set( texture, gltfReference );
+
+					}
+
+				}
+
+				materialParams[ mapName ] = texture;
+
+			} );
+
+		}
+		/**
+   * Assigns final material to a THREE.Mesh, THREE.Line, or THREE.Points instance. The instance
+   * already has a material (generated from the glTF material options alone)
+   * but reuse of the same glTF material may require multiple threejs materials
+   * to accommodate different primitive types, defines, etc. New materials will
+   * be created if necessary, and reused from a cache.
+   * @param  {Object3D} mesh THREE.Mesh, THREE.Line, or THREE.Points instance.
+   */
+
+
+		assignFinalMaterial( mesh ) {
+
+			const geometry = mesh.geometry;
+			let material = mesh.material;
+			const useVertexTangents = geometry.attributes.tangent !== undefined;
+			const useVertexColors = geometry.attributes.color !== undefined;
+			const useFlatShading = geometry.attributes.normal === undefined;
+			const useSkinning = mesh.isSkinnedMesh === true;
+			const useMorphTargets = Object.keys( geometry.morphAttributes ).length > 0;
+			const useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== undefined;
+
+			if ( mesh.isPoints ) {
+
+				const cacheKey = 'PointsMaterial:' + material.uuid;
+				let pointsMaterial = this.cache.get( cacheKey );
+
+				if ( ! pointsMaterial ) {
+
+					pointsMaterial = new THREE.PointsMaterial();
+					THREE.Material.prototype.copy.call( pointsMaterial, material );
+					pointsMaterial.color.copy( material.color );
+					pointsMaterial.map = material.map;
+					pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
+
+					this.cache.add( cacheKey, pointsMaterial );
+
+				}
+
+				material = pointsMaterial;
+
+			} else if ( mesh.isLine ) {
+
+				const cacheKey = 'LineBasicMaterial:' + material.uuid;
+				let lineMaterial = this.cache.get( cacheKey );
+
+				if ( ! lineMaterial ) {
+
+					lineMaterial = new THREE.LineBasicMaterial();
+					THREE.Material.prototype.copy.call( lineMaterial, material );
+					lineMaterial.color.copy( material.color );
+					this.cache.add( cacheKey, lineMaterial );
+
+				}
+
+				material = lineMaterial;
+
+			} // Clone the material if it will be modified
+
+
+			if ( useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets ) {
+
+				let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
+				if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:';
+				if ( useSkinning ) cacheKey += 'skinning:';
+				if ( useVertexTangents ) cacheKey += 'vertex-tangents:';
+				if ( useVertexColors ) cacheKey += 'vertex-colors:';
+				if ( useFlatShading ) cacheKey += 'flat-shading:';
+				if ( useMorphTargets ) cacheKey += 'morph-targets:';
+				if ( useMorphNormals ) cacheKey += 'morph-normals:';
+				let cachedMaterial = this.cache.get( cacheKey );
+
+				if ( ! cachedMaterial ) {
+
+					cachedMaterial = material.clone();
+					if ( useSkinning ) cachedMaterial.skinning = true;
+					if ( useVertexColors ) cachedMaterial.vertexColors = true;
+					if ( useFlatShading ) cachedMaterial.flatShading = true;
+					if ( useMorphTargets ) cachedMaterial.morphTargets = true;
+					if ( useMorphNormals ) cachedMaterial.morphNormals = true;
+
+					if ( useVertexTangents ) {
+
+						cachedMaterial.vertexTangents = true; // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
+
+						if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1;
+						if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1;
+
+					}
+
+					this.cache.add( cacheKey, cachedMaterial );
+					this.associations.set( cachedMaterial, this.associations.get( material ) );
+
+				}
+
+				material = cachedMaterial;
+
+			} // workarounds for mesh and geometry
+
+
+			if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {
+
+				geometry.setAttribute( 'uv2', geometry.attributes.uv );
+
+			}
+
+			mesh.material = material;
+
+		}
+
+		getMaterialType( ) {
+
+			return THREE.MeshStandardMaterial;
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
+   * @param {number} materialIndex
+   * @return {Promise<Material>}
+   */
+
+
+		loadMaterial( materialIndex ) {
+
+			const parser = this;
+			const json = this.json;
+			const extensions = this.extensions;
+			const materialDef = json.materials[ materialIndex ];
+			let materialType;
+			const materialParams = {};
+			const materialExtensions = materialDef.extensions || {};
+			const pending = [];
+
+			if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
+
+				const sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
+				materialType = sgExtension.getMaterialType();
+				pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
+
+			} else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
+
+				const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
+				materialType = kmuExtension.getMaterialType();
+				pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
+
+			} else {
+
+				// Specification:
+				// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
+				const metallicRoughness = materialDef.pbrMetallicRoughness || {};
+				materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
+				materialParams.opacity = 1.0;
+
+				if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
+
+					const array = metallicRoughness.baseColorFactor;
+					materialParams.color.fromArray( array );
+					materialParams.opacity = array[ 3 ];
+
+				}
+
+				if ( metallicRoughness.baseColorTexture !== undefined ) {
+
+					pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) );
+
+				}
+
+				materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
+				materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
+
+				if ( metallicRoughness.metallicRoughnessTexture !== undefined ) {
+
+					pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) );
+					pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) );
+
+				}
+
+				materialType = this._invokeOne( function ( ext ) {
+
+					return ext.getMaterialType && ext.getMaterialType( materialIndex );
+
+				} );
+				pending.push( Promise.all( this._invokeAll( function ( ext ) {
+
+					return ext.extendMaterialParams && ext.extendMaterialParams( materialIndex, materialParams );
+
+				} ) ) );
+
+			}
+
+			if ( materialDef.doubleSided === true ) {
+
+				materialParams.side = THREE.DoubleSide;
+
+			}
+
+			const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
+
+			if ( alphaMode === ALPHA_MODES.BLEND ) {
+
+				materialParams.transparent = true; // See: https://github.com/mrdoob/three.js/issues/17706
+
+				materialParams.depthWrite = false;
+
+			} else {
+
+				materialParams.transparent = false;
+
+				if ( alphaMode === ALPHA_MODES.MASK ) {
+
+					materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
+
+				}
+
+			}
+
+			if ( materialDef.normalTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
+
+				pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) ); // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
+
+				materialParams.normalScale = new THREE.Vector2( 1, - 1 );
+
+				if ( materialDef.normalTexture.scale !== undefined ) {
+
+					materialParams.normalScale.set( materialDef.normalTexture.scale, - materialDef.normalTexture.scale );
+
+				}
+
+			}
+
+			if ( materialDef.occlusionTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
+
+				pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) );
+
+				if ( materialDef.occlusionTexture.strength !== undefined ) {
+
+					materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
+
+				}
+
+			}
+
+			if ( materialDef.emissiveFactor !== undefined && materialType !== THREE.MeshBasicMaterial ) {
+
+				materialParams.emissive = new THREE.Color().fromArray( materialDef.emissiveFactor );
+
+			}
+
+			if ( materialDef.emissiveTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
+
+				pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture ) );
+
+			}
+
+			return Promise.all( pending ).then( function () {
+
+				let material;
+
+				if ( materialType === GLTFMeshStandardSGMaterial ) {
+
+					material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams );
+
+				} else {
+
+					material = new materialType( materialParams );
+
+				}
+
+				if ( materialDef.name ) material.name = materialDef.name; // baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
+
+				if ( material.map ) material.map.encoding = THREE.sRGBEncoding;
+				if ( material.emissiveMap ) material.emissiveMap.encoding = THREE.sRGBEncoding;
+				assignExtrasToUserData( material, materialDef );
+				parser.associations.set( material, {
+					type: 'materials',
+					index: materialIndex
+				} );
+				if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef );
+				return material;
+
+			} );
+
+		}
+		/** When THREE.Object3D instances are targeted by animation, they need unique names. */
+
+
+		createUniqueName( originalName ) {
+
+			const sanitizedName = THREE.PropertyBinding.sanitizeNodeName( originalName || '' );
+			let name = sanitizedName;
+
+			for ( let i = 1; this.nodeNamesUsed[ name ]; ++ i ) {
+
+				name = sanitizedName + '_' + i;
+
+			}
+
+			this.nodeNamesUsed[ name ] = true;
+			return name;
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
+   *
+   * Creates BufferGeometries from primitives.
+   *
+   * @param {Array<GLTF.Primitive>} primitives
+   * @return {Promise<Array<BufferGeometry>>}
+   */
+
+
+		loadGeometries( primitives ) {
+
+			const parser = this;
+			const extensions = this.extensions;
+			const cache = this.primitiveCache;
+
+			function createDracoPrimitive( primitive ) {
+
+				return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ].decodePrimitive( primitive, parser ).then( function ( geometry ) {
+
+					return addPrimitiveAttributes( geometry, primitive, parser );
+
+				} );
+
+			}
+
+			const pending = [];
+
+			for ( let i = 0, il = primitives.length; i < il; i ++ ) {
+
+				const primitive = primitives[ i ];
+				const cacheKey = createPrimitiveKey( primitive ); // See if we've already created this geometry
+
+				const cached = cache[ cacheKey ];
+
+				if ( cached ) {
+
+					// Use the cached geometry if it exists
+					pending.push( cached.promise );
+
+				} else {
+
+					let geometryPromise;
+
+					if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) {
+
+						// Use DRACO geometry if available
+						geometryPromise = createDracoPrimitive( primitive );
+
+					} else {
+
+						// Otherwise create a new geometry
+						geometryPromise = addPrimitiveAttributes( new THREE.BufferGeometry(), primitive, parser );
+
+					} // Cache this geometry
+
+
+					cache[ cacheKey ] = {
+						primitive: primitive,
+						promise: geometryPromise
+					};
+					pending.push( geometryPromise );
+
+				}
+
+			}
+
+			return Promise.all( pending );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
+   * @param {number} meshIndex
+   * @return {Promise<Group|Mesh|SkinnedMesh>}
+   */
+
+
+		loadMesh( meshIndex ) {
+
+			const parser = this;
+			const json = this.json;
+			const extensions = this.extensions;
+			const meshDef = json.meshes[ meshIndex ];
+			const primitives = meshDef.primitives;
+			const pending = [];
+
+			for ( let i = 0, il = primitives.length; i < il; i ++ ) {
+
+				const material = primitives[ i ].material === undefined ? createDefaultMaterial( this.cache ) : this.getDependency( 'material', primitives[ i ].material );
+				pending.push( material );
+
+			}
+
+			pending.push( parser.loadGeometries( primitives ) );
+			return Promise.all( pending ).then( function ( results ) {
+
+				const materials = results.slice( 0, results.length - 1 );
+				const geometries = results[ results.length - 1 ];
+				const meshes = [];
+
+				for ( let i = 0, il = geometries.length; i < il; i ++ ) {
+
+					const geometry = geometries[ i ];
+					const primitive = primitives[ i ]; // 1. create THREE.Mesh
+
+					let mesh;
+					const material = materials[ i ];
+
+					if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === undefined ) {
+
+						// .isSkinnedMesh isn't in glTF spec. See ._markDefs()
+						mesh = meshDef.isSkinnedMesh === true ? new THREE.SkinnedMesh( geometry, material ) : new THREE.Mesh( geometry, material );
+
+						if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
+
+							// we normalize floating point skin weight array to fix malformed assets (see #15319)
+							// it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
+							mesh.normalizeSkinWeights();
+
+						}
+
+						if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) {
+
+							mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleStripDrawMode );
+
+						} else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) {
+
+							mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleFanDrawMode );
+
+						}
+
+					} else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
+
+						mesh = new THREE.LineSegments( geometry, material );
+
+					} else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) {
+
+						mesh = new THREE.Line( geometry, material );
+
+					} else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) {
+
+						mesh = new THREE.LineLoop( geometry, material );
+
+					} else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) {
+
+						mesh = new THREE.Points( geometry, material );
+
+					} else {
+
+						throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode );
+
+					}
+
+					if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) {
+
+						updateMorphTargets( mesh, meshDef );
+
+					}
+
+					mesh.name = parser.createUniqueName( meshDef.name || 'mesh_' + meshIndex );
+					assignExtrasToUserData( mesh, meshDef );
+					if ( primitive.extensions ) addUnknownExtensionsToUserData( extensions, mesh, primitive );
+					parser.assignFinalMaterial( mesh );
+					meshes.push( mesh );
+
+				}
+
+				if ( meshes.length === 1 ) {
+
+					return meshes[ 0 ];
+
+				}
+
+				const group = new THREE.Group();
+
+				for ( let i = 0, il = meshes.length; i < il; i ++ ) {
+
+					group.add( meshes[ i ] );
+
+				}
+
+				return group;
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
+   * @param {number} cameraIndex
+   * @return {Promise<THREE.Camera>}
+   */
+
+
+		loadCamera( cameraIndex ) {
+
+			let camera;
+			const cameraDef = this.json.cameras[ cameraIndex ];
+			const params = cameraDef[ cameraDef.type ];
+
+			if ( ! params ) {
+
+				console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
+				return;
+
+			}
+
+			if ( cameraDef.type === 'perspective' ) {
+
+				camera = new THREE.PerspectiveCamera( THREE.MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 );
+
+			} else if ( cameraDef.type === 'orthographic' ) {
+
+				camera = new THREE.OrthographicCamera( - params.xmag, params.xmag, params.ymag, - params.ymag, params.znear, params.zfar );
+
+			}
+
+			if ( cameraDef.name ) camera.name = this.createUniqueName( cameraDef.name );
+			assignExtrasToUserData( camera, cameraDef );
+			return Promise.resolve( camera );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
+   * @param {number} skinIndex
+   * @return {Promise<Object>}
+   */
+
+
+		loadSkin( skinIndex ) {
+
+			const skinDef = this.json.skins[ skinIndex ];
+			const skinEntry = {
+				joints: skinDef.joints
+			};
+
+			if ( skinDef.inverseBindMatrices === undefined ) {
+
+				return Promise.resolve( skinEntry );
+
+			}
+
+			return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) {
+
+				skinEntry.inverseBindMatrices = accessor;
+				return skinEntry;
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
+   * @param {number} animationIndex
+   * @return {Promise<AnimationClip>}
+   */
+
+
+		loadAnimation( animationIndex ) {
+
+			const json = this.json;
+			const animationDef = json.animations[ animationIndex ];
+			const pendingNodes = [];
+			const pendingInputAccessors = [];
+			const pendingOutputAccessors = [];
+			const pendingSamplers = [];
+			const pendingTargets = [];
+
+			for ( let i = 0, il = animationDef.channels.length; i < il; i ++ ) {
+
+				const channel = animationDef.channels[ i ];
+				const sampler = animationDef.samplers[ channel.sampler ];
+				const target = channel.target;
+				const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.
+
+				const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
+				const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
+				pendingNodes.push( this.getDependency( 'node', name ) );
+				pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
+				pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
+				pendingSamplers.push( sampler );
+				pendingTargets.push( target );
+
+			}
+
+			return Promise.all( [ Promise.all( pendingNodes ), Promise.all( pendingInputAccessors ), Promise.all( pendingOutputAccessors ), Promise.all( pendingSamplers ), Promise.all( pendingTargets ) ] ).then( function ( dependencies ) {
+
+				const nodes = dependencies[ 0 ];
+				const inputAccessors = dependencies[ 1 ];
+				const outputAccessors = dependencies[ 2 ];
+				const samplers = dependencies[ 3 ];
+				const targets = dependencies[ 4 ];
+				const tracks = [];
+
+				for ( let i = 0, il = nodes.length; i < il; i ++ ) {
+
+					const node = nodes[ i ];
+					const inputAccessor = inputAccessors[ i ];
+					const outputAccessor = outputAccessors[ i ];
+					const sampler = samplers[ i ];
+					const target = targets[ i ];
+					if ( node === undefined ) continue;
+					node.updateMatrix();
+					node.matrixAutoUpdate = true;
+					let TypedKeyframeTrack;
+
+					switch ( PATH_PROPERTIES[ target.path ] ) {
+
+						case PATH_PROPERTIES.weights:
+							TypedKeyframeTrack = THREE.NumberKeyframeTrack;
+							break;
+
+						case PATH_PROPERTIES.rotation:
+							TypedKeyframeTrack = THREE.QuaternionKeyframeTrack;
+							break;
+
+						case PATH_PROPERTIES.position:
+						case PATH_PROPERTIES.scale:
+						default:
+							TypedKeyframeTrack = THREE.VectorKeyframeTrack;
+							break;
+
+					}
+
+					const targetName = node.name ? node.name : node.uuid;
+					const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;
+					const targetNames = [];
+
+					if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) {
+
+						// Node may be a THREE.Group (glTF mesh with several primitives) or a THREE.Mesh.
+						node.traverse( function ( object ) {
+
+							if ( object.isMesh === true && object.morphTargetInfluences ) {
+
+								targetNames.push( object.name ? object.name : object.uuid );
+
+							}
+
+						} );
+
+					} else {
+
+						targetNames.push( targetName );
+
+					}
+
+					let outputArray = outputAccessor.array;
+
+					if ( outputAccessor.normalized ) {
+
+						const scale = getNormalizedComponentScale( outputArray.constructor );
+						const scaled = new Float32Array( outputArray.length );
+
+						for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
+
+							scaled[ j ] = outputArray[ j ] * scale;
+
+						}
+
+						outputArray = scaled;
+
+					}
+
+					for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) {
+
+						const track = new TypedKeyframeTrack( targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ], inputAccessor.array, outputArray, interpolation ); // Override interpolation with custom factory method.
+
+						if ( sampler.interpolation === 'CUBICSPLINE' ) {
+
+							track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
+
+								// A CUBICSPLINE keyframe in glTF has three output values for each input value,
+								// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
+								// must be divided by three to get the interpolant's sampleSize argument.
+								return new GLTFCubicSplineInterpolant( this.times, this.values, this.getValueSize() / 3, result );
+
+							}; // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
+
+
+							track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
+
+						}
+
+						tracks.push( track );
+
+					}
+
+				}
+
+				const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
+				return new THREE.AnimationClip( name, undefined, tracks );
+
+			} );
+
+		}
+
+		createNodeMesh( nodeIndex ) {
+
+			const json = this.json;
+			const parser = this;
+			const nodeDef = json.nodes[ nodeIndex ];
+			if ( nodeDef.mesh === undefined ) return null;
+			return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
+
+				const node = parser._getNodeRef( parser.meshCache, nodeDef.mesh, mesh ); // if weights are provided on the node, override weights on the mesh.
+
+
+				if ( nodeDef.weights !== undefined ) {
+
+					node.traverse( function ( o ) {
+
+						if ( ! o.isMesh ) return;
+
+						for ( let i = 0, il = nodeDef.weights.length; i < il; i ++ ) {
+
+							o.morphTargetInfluences[ i ] = nodeDef.weights[ i ];
+
+						}
+
+					} );
+
+				}
+
+				return node;
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
+   * @param {number} nodeIndex
+   * @return {Promise<Object3D>}
+   */
+
+
+		loadNode( nodeIndex ) {
+
+			const json = this.json;
+			const extensions = this.extensions;
+			const parser = this;
+			const nodeDef = json.nodes[ nodeIndex ]; // reserve node's name before its dependencies, so the root has the intended name.
+
+			const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
+			return function () {
+
+				const pending = [];
+
+				const meshPromise = parser._invokeOne( function ( ext ) {
+
+					return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
+
+				} );
+
+				if ( meshPromise ) {
+
+					pending.push( meshPromise );
+
+				}
+
+				if ( nodeDef.camera !== undefined ) {
+
+					pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
+
+						return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
+
+					} ) );
+
+				}
+
+				parser._invokeAll( function ( ext ) {
+
+					return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
+
+				} ).forEach( function ( promise ) {
+
+					pending.push( promise );
+
+				} );
+
+				return Promise.all( pending );
+
+			}().then( function ( objects ) {
+
+				let node; // .isBone isn't in glTF spec. See ._markDefs
+
+				if ( nodeDef.isBone === true ) {
+
+					node = new THREE.Bone();
+
+				} else if ( objects.length > 1 ) {
+
+					node = new THREE.Group();
+
+				} else if ( objects.length === 1 ) {
+
+					node = objects[ 0 ];
+
+				} else {
+
+					node = new THREE.Object3D();
+
+				}
+
+				if ( node !== objects[ 0 ] ) {
+
+					for ( let i = 0, il = objects.length; i < il; i ++ ) {
+
+						node.add( objects[ i ] );
+
+					}
+
+				}
+
+				if ( nodeDef.name ) {
+
+					node.userData.name = nodeDef.name;
+					node.name = nodeName;
+
+				}
+
+				assignExtrasToUserData( node, nodeDef );
+				if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef );
+
+				if ( nodeDef.matrix !== undefined ) {
+
+					const matrix = new THREE.Matrix4();
+					matrix.fromArray( nodeDef.matrix );
+					node.applyMatrix4( matrix );
+
+				} else {
+
+					if ( nodeDef.translation !== undefined ) {
+
+						node.position.fromArray( nodeDef.translation );
+
+					}
+
+					if ( nodeDef.rotation !== undefined ) {
+
+						node.quaternion.fromArray( nodeDef.rotation );
+
+					}
+
+					if ( nodeDef.scale !== undefined ) {
+
+						node.scale.fromArray( nodeDef.scale );
+
+					}
+
+				}
+
+				parser.associations.set( node, {
+					type: 'nodes',
+					index: nodeIndex
+				} );
+				return node;
+
+			} );
+
+		}
+		/**
+   * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
+   * @param {number} sceneIndex
+   * @return {Promise<Group>}
+   */
+
+
+		loadScene( sceneIndex ) {
+
+			const json = this.json;
+			const extensions = this.extensions;
+			const sceneDef = this.json.scenes[ sceneIndex ];
+			const parser = this; // THREE.Loader returns THREE.Group, not Scene.
+			// See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
+
+			const scene = new THREE.Group();
+			if ( sceneDef.name ) scene.name = parser.createUniqueName( sceneDef.name );
+			assignExtrasToUserData( scene, sceneDef );
+			if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef );
+			const nodeIds = sceneDef.nodes || [];
+			const pending = [];
+
+			for ( let i = 0, il = nodeIds.length; i < il; i ++ ) {
+
+				pending.push( buildNodeHierachy( nodeIds[ i ], scene, json, parser ) );
+
+			}
+
+			return Promise.all( pending ).then( function () {
+
+				return scene;
+
+			} );
+
+		}
+
+	}
+
+	function buildNodeHierachy( nodeId, parentObject, json, parser ) {
+
+		const nodeDef = json.nodes[ nodeId ];
+		return parser.getDependency( 'node', nodeId ).then( function ( node ) {
+
+			if ( nodeDef.skin === undefined ) return node; // build skeleton here as well
+
+			let skinEntry;
+			return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) {
+
+				skinEntry = skin;
+				const pendingJoints = [];
+
+				for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) {
+
+					pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) );
+
+				}
+
+				return Promise.all( pendingJoints );
+
+			} ).then( function ( jointNodes ) {
+
+				node.traverse( function ( mesh ) {
+
+					if ( ! mesh.isMesh ) return;
+					const bones = [];
+					const boneInverses = [];
+
+					for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) {
+
+						const jointNode = jointNodes[ j ];
+
+						if ( jointNode ) {
+
+							bones.push( jointNode );
+							const mat = new THREE.Matrix4();
+
+							if ( skinEntry.inverseBindMatrices !== undefined ) {
+
+								mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 );
+
+							}
+
+							boneInverses.push( mat );
+
+						} else {
+
+							console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] );
+
+						}
+
+					}
+
+					mesh.bind( new THREE.Skeleton( bones, boneInverses ), mesh.matrixWorld );
+
+				} );
+				return node;
+
+			} );
+
+		} ).then( function ( node ) {
+
+			// build node hierachy
+			parentObject.add( node );
+			const pending = [];
+
+			if ( nodeDef.children ) {
+
+				const children = nodeDef.children;
+
+				for ( let i = 0, il = children.length; i < il; i ++ ) {
+
+					const child = children[ i ];
+					pending.push( buildNodeHierachy( child, node, json, parser ) );
+
+				}
+
+			}
+
+			return Promise.all( pending );
+
+		} );
+
+	}
+	/**
+ * @param {BufferGeometry} geometry
+ * @param {GLTF.Primitive} primitiveDef
+ * @param {GLTFParser} parser
+ */
+
+
+	function computeBounds( geometry, primitiveDef, parser ) {
+
+		const attributes = primitiveDef.attributes;
+		const box = new THREE.Box3();
+
+		if ( attributes.POSITION !== undefined ) {
+
+			const accessor = parser.json.accessors[ attributes.POSITION ];
+			const min = accessor.min;
+			const max = accessor.max; // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
+
+			if ( min !== undefined && max !== undefined ) {
+
+				box.set( new THREE.Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ), new THREE.Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) );
+
+				if ( accessor.normalized ) {
+
+					const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
+					box.min.multiplyScalar( boxScale );
+					box.max.multiplyScalar( boxScale );
+
+				}
+
+			} else {
+
+				console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
+				return;
+
+			}
+
+		} else {
+
+			return;
+
+		}
+
+		const targets = primitiveDef.targets;
+
+		if ( targets !== undefined ) {
+
+			const maxDisplacement = new THREE.Vector3();
+			const vector = new THREE.Vector3();
+
+			for ( let i = 0, il = targets.length; i < il; i ++ ) {
+
+				const target = targets[ i ];
+
+				if ( target.POSITION !== undefined ) {
+
+					const accessor = parser.json.accessors[ target.POSITION ];
+					const min = accessor.min;
+					const max = accessor.max; // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
+
+					if ( min !== undefined && max !== undefined ) {
+
+						// we need to get max of absolute components because target weight is [-1,1]
+						vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
+						vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
+						vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
+
+						if ( accessor.normalized ) {
+
+							const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
+							vector.multiplyScalar( boxScale );
+
+						} // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative
+						// to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets
+						// are used to implement key-frame animations and as such only two are active at a time - this results in very large
+						// boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.
+
+
+						maxDisplacement.max( vector );
+
+					} else {
+
+						console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
+
+					}
+
+				}
+
+			} // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.
+
+
+			box.expandByVector( maxDisplacement );
+
+		}
+
+		geometry.boundingBox = box;
+		const sphere = new THREE.Sphere();
+		box.getCenter( sphere.center );
+		sphere.radius = box.min.distanceTo( box.max ) / 2;
+		geometry.boundingSphere = sphere;
+
+	}
+	/**
+ * @param {BufferGeometry} geometry
+ * @param {GLTF.Primitive} primitiveDef
+ * @param {GLTFParser} parser
+ * @return {Promise<BufferGeometry>}
+ */
+
+
+	function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
+
+		const attributes = primitiveDef.attributes;
+		const pending = [];
+
+		function assignAttributeAccessor( accessorIndex, attributeName ) {
+
+			return parser.getDependency( 'accessor', accessorIndex ).then( function ( accessor ) {
+
+				geometry.setAttribute( attributeName, accessor );
+
+			} );
+
+		}
+
+		for ( const gltfAttributeName in attributes ) {
+
+			const threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase(); // Skip attributes already provided by e.g. Draco extension.
+
+			if ( threeAttributeName in geometry.attributes ) continue;
+			pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) );
+
+		}
+
+		if ( primitiveDef.indices !== undefined && ! geometry.index ) {
+
+			const accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) {
+
+				geometry.setIndex( accessor );
+
+			} );
+			pending.push( accessor );
+
+		}
+
+		assignExtrasToUserData( geometry, primitiveDef );
+		computeBounds( geometry, primitiveDef, parser );
+		return Promise.all( pending ).then( function () {
+
+			return primitiveDef.targets !== undefined ? addMorphTargets( geometry, primitiveDef.targets, parser ) : geometry;
+
+		} );
+
+	}
+	/**
+ * @param {BufferGeometry} geometry
+ * @param {Number} drawMode
+ * @return {BufferGeometry}
+ */
+
+
+	function toTrianglesDrawMode( geometry, drawMode ) {
+
+		let index = geometry.getIndex(); // generate index if not present
+
+		if ( index === null ) {
+
+			const indices = [];
+			const position = geometry.getAttribute( 'position' );
+
+			if ( position !== undefined ) {
+
+				for ( let i = 0; i < position.count; i ++ ) {
+
+					indices.push( i );
+
+				}
+
+				geometry.setIndex( indices );
+				index = geometry.getIndex();
+
+			} else {
+
+				console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
+				return geometry;
+
+			}
+
+		} //
+
+
+		const numberOfTriangles = index.count - 2;
+		const newIndices = [];
+
+		if ( drawMode === THREE.TriangleFanDrawMode ) {
+
+			// gl.TRIANGLE_FAN
+			for ( let i = 1; i <= numberOfTriangles; i ++ ) {
+
+				newIndices.push( index.getX( 0 ) );
+				newIndices.push( index.getX( i ) );
+				newIndices.push( index.getX( i + 1 ) );
+
+			}
+
+		} else {
+
+			// gl.TRIANGLE_STRIP
+			for ( let i = 0; i < numberOfTriangles; i ++ ) {
+
+				if ( i % 2 === 0 ) {
+
+					newIndices.push( index.getX( i ) );
+					newIndices.push( index.getX( i + 1 ) );
+					newIndices.push( index.getX( i + 2 ) );
+
+				} else {
+
+					newIndices.push( index.getX( i + 2 ) );
+					newIndices.push( index.getX( i + 1 ) );
+					newIndices.push( index.getX( i ) );
+
+				}
+
+			}
+
+		}
+
+		if ( newIndices.length / 3 !== numberOfTriangles ) {
+
+			console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
+
+		} // build final geometry
+
+
+		const newGeometry = geometry.clone();
+		newGeometry.setIndex( newIndices );
+		return newGeometry;
+
+	}
+
+	THREE.GLTFLoader = GLTFLoader;
+
+} )();
diff --git a/public/js/showroom.js b/public/js/showroom.js
index 116d41d..6ee3c2f 100644
--- a/public/js/showroom.js
+++ b/public/js/showroom.js
@@ -710,6 +710,9 @@ function buildRoom() {
     roughness: 1.0, metalness: 0.0, envMapIntensity: 0.35
   }));
   floorMesh.rotation.x = -Math.PI/2; floorMesh.receiveShadow = true; scene.add(floorMesh);
+  window._floorMesh = floorMesh;              // tagged so a room type can swap its material + resizeRoom can dispose it
+  // Décor tracker (baseboards/crown/strips/glows/sign) so resizeRoom can dispose the whole shell.
+  window._shellDecor = [];
 
   // Ceiling — clean, bright, EVEN soft warm off-white gallery ceiling. (Was a crude
   // 64px procedural grid that read as a wireframe — see REVIEW.md.) No texture, no
@@ -738,7 +741,7 @@ function buildRoom() {
     const strip = new THREE.Mesh(new THREE.PlaneGeometry(0.10, D * 0.78), stripMat);
     strip.rotation.x = Math.PI / 2;
     strip.position.set(sx, H - 0.012, 0);
-    scene.add(strip);
+    scene.add(strip); window._shellDecor.push(strip);
     // Soft bloom halo just below the ceiling, a touch wider, additive + translucent.
     const glow = new THREE.Mesh(
       new THREE.PlaneGeometry(0.55, D * 0.86),
@@ -750,7 +753,7 @@ function buildRoom() {
     glow.rotation.x = Math.PI / 2;
     glow.position.set(sx, H - 0.02, 0);   // a hair below the strip so it never z-fights
     glow.renderOrder = 3;
-    scene.add(glow);
+    scene.add(glow); window._shellDecor.push(glow);
   });
 
   // Walls — capture ALL FOUR surfaces so a focused pattern clads the whole room
@@ -775,7 +778,7 @@ function buildRoom() {
   // Baseboards
   [[0, 0.04, -D/2+0.02, W, 0.08, 0.04], [-W/2+0.02, 0.04, 0, 0.04, 0.08, D], [W/2-0.02, 0.04, 0, 0.04, 0.08, D]].forEach(b => {
     const m = new THREE.Mesh(new THREE.BoxGeometry(b[3],b[4],b[5]), MAT.baseboard);
-    m.position.set(b[0],b[1],b[2]); scene.add(m);
+    m.position.set(b[0],b[1],b[2]); scene.add(m); window._shellDecor.push(m);
   });
 
   // Crown molding — thin profile along ceiling edges
@@ -788,7 +791,7 @@ function buildRoom() {
   ];
   crownData.forEach(([cx, cy, cz, cw, ch, cd]) => {
     const m = new THREE.Mesh(new THREE.BoxGeometry(cw, ch, cd), crownMat);
-    m.position.set(cx, cy, cz); scene.add(m);
+    m.position.set(cx, cy, cz); scene.add(m); window._shellDecor.push(m);
   });
 
   // DW entrance sign above doorway
@@ -806,7 +809,7 @@ function buildRoom() {
   );
   signMesh.position.set(0, H - 0.35, D/2 - 0.02);
   signMesh.rotation.y = Math.PI;
-  scene.add(signMesh);
+  scene.add(signMesh); window._shellDecor.push(signMesh);
 }
 
 function addWall(x, y, z, w, h, rotY, mat) {
@@ -3696,6 +3699,34 @@ function initHUD() {
     });
   }
 
+  // ---- ADJUSTABLE ROOM sliders (Phase 2) — W / D / H. resizeRoom tears down + rebuilds
+  // the shell + wing arc + active room-type furniture. Fires on 'change' (drag-release)
+  // so a rebuild isn't triggered every tick. Persisted to qh_room_w / _d / _h.
+  const rw = document.getElementById('room-w-range'), rwv = document.getElementById('room-w-val');
+  const rd = document.getElementById('room-d-range'), rdv = document.getElementById('room-d-val');
+  const rh = document.getElementById('room-h-range'), rhv = document.getElementById('room-h-val');
+  const _lsNum = (k, d) => { const v = parseFloat(localStorage.getItem(k)); return (v > 0 ? v : d); };
+  if (rw && rd && rh) {
+    // Restore persisted dims onto the sliders (do NOT resize on boot — the room-type
+    // engine builds into the current CONFIG dims; a boot resize would double-build).
+    rw.value = _lsNum('qh_room_w', CONFIG.room.width);
+    rd.value = _lsNum('qh_room_d', CONFIG.room.depth);
+    rh.value = _lsNum('qh_room_h', CONFIG.room.height);
+    if (rwv) rwv.textContent = (+rw.value).toFixed(1) + 'm';
+    if (rdv) rdv.textContent = (+rd.value).toFixed(1) + 'm';
+    if (rhv) rhv.textContent = (+rh.value).toFixed(1) + 'm';
+    const liveLabel = () => { if (rwv) rwv.textContent = (+rw.value).toFixed(1) + 'm'; if (rdv) rdv.textContent = (+rd.value).toFixed(1) + 'm'; if (rhv) rhv.textContent = (+rh.value).toFixed(1) + 'm'; };
+    rw.addEventListener('input', liveLabel); rd.addEventListener('input', liveLabel); rh.addEventListener('input', liveLabel);
+    const doResize = () => { try { resizeRoom(parseFloat(rw.value), parseFloat(rd.value), parseFloat(rh.value)); } catch (e) { console.warn('resizeRoom failed', e); } };
+    rw.addEventListener('change', doResize); rd.addEventListener('change', doResize); rh.addEventListener('change', doResize);
+    // If persisted dims differ from the current CONFIG, apply once after boot settles
+    // (after products + room type are built), so a returning user's saved size restores.
+    const wantW = _lsNum('qh_room_w', CONFIG.room.width), wantD = _lsNum('qh_room_d', CONFIG.room.depth), wantH = _lsNum('qh_room_h', CONFIG.room.height);
+    if (Math.abs(wantW - CONFIG.room.width) > 0.05 || Math.abs(wantD - CONFIG.room.depth) > 0.05 || Math.abs(wantH - CONFIG.room.height) > 0.05) {
+      setTimeout(() => { try { resizeRoom(wantW, wantD, wantH); } catch (e) {} }, 1600);
+    }
+  }
+
   // ---- GUIDED MODE wiring (senior-first big buttons) ----
   const gPrev = document.getElementById('g-prev');
   const gNext = document.getElementById('g-next');
@@ -4007,6 +4038,754 @@ window._getSceneStats = function() {
   return { total, meshes, groups, lights, drawCalls: ri.render.calls, triangles: ri.render.triangles, textures: ri.memory.textures, geometries: ri.memory.geometries, programs: ri.programs ? ri.programs.length : 'n/a' };
 };
 
+// ============================================================
+// ROOM TYPES (Phase 2) — 5 furnished room presets, parallel to THEMES/MODES.
+// ------------------------------------------------------------
+// Each record is a data descriptor (geometry, clad-vs-painted walls, floor,
+// ceiling fixture, furniture layout, lighting rig, camera, palette hook) per
+// docs/ROOM-TYPES-SPEC.md. buildRoomType(key) tears down the previous type's
+// furniture + fixtures + fixture-lights and rebuilds the chosen one, adjusting
+// floor/paint/lights to match. The wing-arc showroom shell stays; a room type
+// dresses the SAME box (or, via resizeRoom, a rebuilt box) with real furniture.
+//
+// HYBRID furniture (DTD verdict C): every piece is FIRST a crafted THREE
+// primitive (ships fully offline). GLTFLoader then LAZY-loads CC0/public-domain
+// hero GLBs for the active room only and swaps them over the matching primitive;
+// a missing/failed model keeps the primitive (never ship broken/unlicensed).
+// ============================================================
+const PI = Math.PI;
+
+// Color-bucket → accent-tone map for the palette hook. Soft goods (rug / duvet /
+// pillows / sofa upholstery) chase the wallcovering's warm/cool bias; wood / stone
+// / leather anchors never move (60-30-10, pattern = the 60). Falls back to neutral
+// when the product carries no color_bucket/hue (the live China Seas feed does not).
+function accentTone(bucket, hue) {
+  // Prefer an explicit bucket; else derive a coarse warm/cool from hue degrees.
+  let b = (bucket || '').toLowerCase();
+  if (!b && typeof hue === 'number') {
+    b = (hue < 75 || hue >= 330) ? 'warm' : (hue >= 75 && hue < 165) ? 'cool-green' : 'cool';
+  }
+  if (/red|orange|gold|brown|terracotta|warm|ochre|rust/.test(b)) return { soft: 0xd8b48c, throw: 0xb0663c, rug: 0xc2a578 };
+  if (/green|sage|olive|cool-green/.test(b))                       return { soft: 0xb9c2ab, throw: 0x6f7a5a, rug: 0xa7ac96 };
+  if (/blue|indigo|teal|purple|violet|cool|slate/.test(b))         return { soft: 0xa9b4c4, throw: 0x4a5a72, rug: 0x9aa2ac };
+  return { soft: 0xcfc4b0, throw: 0xb9a88c, rug: 0xb9a88c }; // neutral cream default
+}
+
+// Gallery spot-temperature hook: cool patterns → shift spots toward neutral so they
+// don't go muddy; warm patterns keep the warm 0xffe6bd. True = use the cool spot.
+function _galleryCoolSpot() {
+  let p = null;
+  if (focusedWing && focusedWing.userData && focusedWing.userData.product) p = focusedWing.userData.product;
+  else if (centerBook && centerBook.product) p = centerBook.product;
+  const b = (p && p.color_bucket || '').toLowerCase();
+  const hue = p && typeof p.hue === 'number' ? p.hue : null;
+  if (/blue|indigo|teal|purple|violet|cool|slate|green|sage/.test(b)) return true;
+  if (hue != null && hue >= 75 && hue < 300) return true;
+  return false;
+}
+
+// Read the active room's product color context (from the focused wing / center book).
+function activePaletteCtx() {
+  let p = null;
+  if (focusedWing && focusedWing.userData && focusedWing.userData.product) p = focusedWing.userData.product;
+  else if (centerBook && centerBook.product) p = centerBook.product;
+  return accentTone(p && p.color_bucket, p && p.hue);
+}
+
+// ---- ROOM_TYPES registry -------------------------------------------------
+const ROOM_TYPES = {
+  bedroom: {
+    label: 'Bedroom',
+    room: { width: 4.6, depth: 5.0, height: 2.7 },
+    clad: ['back'],
+    paint: 0xece4d6,
+    floor: 'oak',
+    ceiling: 0xf2eee5,
+    fixture: 'pendant',
+    mood: 'warm-dim',
+    lights: { ambient: [0xfff0dd, 0.30], hemi: [0xfff1e0, 0xe4d8c4, 0.28],
+              key: { color: 0xfff2e0, intensity: 0.75, radius: 4 }, fill: [0xdfe6ff, 0.18], pic: 0.30 },
+    camera: { pos: [0, 1.55, 'D/2-1.4'], look: [0, 1.4, '-D/2+0.4'], fov: 55 },
+    furniture: 'bedroom'
+  },
+  office: {
+    label: 'Office',
+    room: { width: 4.8, depth: 5.2, height: 2.8 },
+    clad: ['back'],
+    paint: 0xf1f1ee,
+    floor: 'concrete',   // no texture → flat MeshStandard fallback
+    ceiling: 0xf4f4f0,
+    fixture: 'track-recessed',
+    mood: 'neutral-bright',
+    lights: { ambient: [0xffffff, 0.50], hemi: [0xf4f6ff, 0xdedad2, 0.45],
+              key: { color: 0xfff8f2, intensity: 1.0, radius: 2.5 }, fill: [0xeef2ff, 0.35], pic: 0.25 },
+    camera: { pos: [0, 1.6, 'D/2-1.0'], look: [0, 1.35, '-D/2+0.3'], fov: 58 },
+    furniture: 'office'
+  },
+  lobby: {
+    label: 'Hotel Lobby',
+    room: { width: 8.0, depth: 8.0, height: 4.2 },
+    clad: ['back'],
+    paint: 0xe6dccb,
+    floor: 'stone',
+    ceiling: 0xece6da,
+    fixture: 'chandelier',
+    mood: 'dramatic',
+    lights: { ambient: [0x2a2620, 0.30], hemi: [0x4a4436, 0x1a1712, 0.25],
+              key: { color: 0xfff1da, intensity: 1.15, radius: 4 }, fill: [0xffd9a8, 0.20],
+              rim: [0xffe6bd, 0.30], pic: 0.60 },
+    camera: { pos: [0.8, 1.6, 'D/2-1.5'], look: [0, 1.8, '-D/2+0.9'], fov: 65 },
+    furniture: 'lobby'
+  },
+  living: {
+    label: 'Living Room',
+    room: { width: 6.10, depth: 6.10, height: 2.9 },
+    clad: ['back'],
+    paint: null,        // keep MAT.wall limewash
+    floor: 'oak',
+    ceiling: 0xf2eee5,
+    fixture: 'flush-mount',
+    mood: 'warm',
+    lights: { ambient: [0xffe8cf, 0.30], hemi: [0xfff3e0, 0x3a2f26, 0.40],
+              key: { color: 0xfff1da, intensity: 1.0, radius: 3.5 }, fill: [0xdfe6ff, 0.25], pic: 0.55 },
+    camera: { pos: [0, 1.5, 'D/2-1.6'], look: [0, 1.3, '-D/2+0.6'], fov: 58 },
+    furniture: 'living'
+  },
+  gallery: {
+    label: 'Art Gallery',
+    room: { width: 7.0, depth: 7.0, height: 3.8 },
+    clad: ['back'],
+    paint: 0x161a22,
+    floor: 'dark-concrete',
+    ceiling: 0x14161c,
+    fixture: 'track-spots',
+    mood: 'high-contrast',
+    lights: { ambient: [0x161a22, 0.42], hemi: [0x161a22, 0x0a0c10, 0.05],
+              key: { color: 0xffe6bd, intensity: 0.55, radius: 3 }, fill: [0x6f7d96, 0.22],
+              rim: [0xffd9a0, 0.30], pic: 0.20 },
+    camera: { pos: [0, 1.55, 'D/2-1.8'], look: [0, 1.6, '-D/2+0.05'], fov: 52 },
+    furniture: 'gallery'
+  }
+};
+const ROOM_TYPE_ORDER = ['bedroom', 'office', 'living', 'lobby', 'gallery'];
+
+// Active room-type state.
+let currentRoomType = null;
+let roomTypeGroup = null;        // holds furniture + fixture meshes for the active type
+let roomTypeLights = [];         // fixture-owned lights (point/spot) — removed on teardown
+const heroModelCache = {};       // url → THREE.Group (parsed GLB), reused across rebuilds
+
+// ---- FLOOR materials -----------------------------------------------------
+// Only floor-oak + floor-stone textures exist on disk (honest per spec). concrete /
+// dark-concrete are flat/procedural MeshStandard fallbacks.
+const _floorMatCache = {};
+function floorMaterial(kind) {
+  if (_floorMatCache[kind]) return _floorMatCache[kind];
+  let m;
+  if (kind === 'oak') {
+    m = new THREE.MeshStandardMaterial({
+      map: loadTex('floor-oak', 2.4, 2.4),
+      normalMap: loadDataTex('floor-oak-normal', 2.4, 2.4),
+      roughnessMap: loadDataTex('floor-oak-rough', 2.4, 2.4),
+      normalScale: new THREE.Vector2(0.55, 0.55), roughness: 1.0, metalness: 0.0, envMapIntensity: 0.35
+    });
+  } else if (kind === 'stone') {
+    const t = srgb(loadTex('floor-stone', 2.4, 2.4));
+    if (renderer && renderer.capabilities) t.anisotropy = renderer.capabilities.getMaxAnisotropy();
+    m = new THREE.MeshStandardMaterial({ map: t, roughness: 0.3, metalness: 0.05, envMapIntensity: 0.7 });
+  } else if (kind === 'concrete') {
+    m = new THREE.MeshStandardMaterial({ color: 0x9a9a98, roughness: 0.35, metalness: 0.05, envMapIntensity: 0.4 });
+  } else { // dark-concrete (gallery)
+    m = new THREE.MeshStandardMaterial({ color: 0x2a2a2c, roughness: 0.4, metalness: 0.05, envMapIntensity: 0.35 });
+  }
+  _floorMatCache[kind] = m;
+  return m;
+}
+// The floor mesh built by buildRoom — retagged so a room type can swap its material.
+function setFloorMaterial(kind) {
+  if (window._floorMesh) window._floorMesh.material = floorMaterial(kind);
+}
+
+// ---- shared soft-good / anchor materials (created lazily) -----------------
+function stdMat(color, rough, metal) { return new THREE.MeshStandardMaterial({ color, roughness: rough == null ? 0.8 : rough, metalness: metal || 0.0, envMapIntensity: 0.4 }); }
+function emissiveMat(color, intensity) { return new THREE.MeshStandardMaterial({ color: 0xfff4e0, emissive: color, emissiveIntensity: intensity == null ? 0.5 : intensity, roughness: 1.0 }); }
+
+// ---- FURNITURE PRIMITIVES (upgraded, ported from proto/v9) ----------------
+// Every builder appends to `g` (the roomTypeGroup) so teardown is a single removal.
+// Positions are already in the room-center frame (viewer faces -z, back = -D/2).
+
+function craftSofa(g, x, z, rotY, tone) {
+  const grp = new THREE.Group();
+  const body = stdMat(tone.soft, 0.95, 0.0);
+  const seatMat = stdMat(0xe7ddc8, 1.0, 0.0);
+  const base = new THREE.Mesh(new THREE.BoxGeometry(2.2, 0.45, 0.95), body); base.position.y = 0.32; base.castShadow = base.receiveShadow = true; grp.add(base);
+  const back = new THREE.Mesh(new THREE.BoxGeometry(2.2, 0.7, 0.22), body); back.position.set(0, 0.62, -0.36); back.castShadow = true; grp.add(back);
+  const seat = new THREE.Mesh(new THREE.BoxGeometry(2.05, 0.18, 0.78), seatMat); seat.position.set(0, 0.58, 0.04); seat.castShadow = true; grp.add(seat);
+  [-1.0, 1.0].forEach(ax => { const a = new THREE.Mesh(new THREE.BoxGeometry(0.2, 0.6, 0.95), body); a.position.set(ax, 0.45, 0); a.castShadow = true; grp.add(a); });
+  // Two accent throw pillows (the 10 of 60-30-10).
+  [-0.55, 0.55].forEach(px => { const pil = new THREE.Mesh(new THREE.BoxGeometry(0.34, 0.30, 0.14), stdMat(tone.throw, 0.9, 0.0)); pil.position.set(px, 0.74, -0.22); pil.rotation.z = px < 0 ? 0.2 : -0.2; pil.castShadow = true; grp.add(pil); });
+  grp.position.set(x, 0, z); grp.rotation.y = rotY; g.add(grp);
+  addContactShadow(x, z, 2.4, 1.1, 0.6);
+}
+
+function craftBed(g, x, z, tone) {
+  const grp = new THREE.Group();
+  const wood = MAT.wood, duvet = stdMat(tone.soft, 0.95, 0.0);
+  const frame = new THREE.Mesh(new THREE.BoxGeometry(1.95, 0.28, 2.15), wood); frame.position.set(0, 0.14, 0); frame.castShadow = frame.receiveShadow = true; grp.add(frame);
+  const mattress = new THREE.Mesh(new THREE.BoxGeometry(1.8, 0.22, 2.05), stdMat(0xf0ece2, 1.0, 0.0)); mattress.position.set(0, 0.39, 0.02); mattress.castShadow = true; grp.add(mattress);
+  const duv = new THREE.Mesh(new THREE.BoxGeometry(1.86, 0.14, 1.5), duvet); duv.position.set(0, 0.52, 0.28); duv.castShadow = true; grp.add(duv);
+  // Two pillows against the headboard side.
+  [-0.42, 0.42].forEach(px => { const pw = new THREE.Mesh(new THREE.BoxGeometry(0.62, 0.16, 0.34), stdMat(0xfaf6ee, 1.0, 0.0)); pw.position.set(px, 0.52, -0.72); pw.castShadow = true; grp.add(pw); });
+  // A folded accent throw at the foot (chases the hue).
+  const thr = new THREE.Mesh(new THREE.BoxGeometry(1.86, 0.06, 0.5), stdMat(tone.throw, 0.9, 0.0)); thr.position.set(0, 0.6, 0.78); thr.castShadow = true; grp.add(thr);
+  grp.position.set(x, 0, z); g.add(grp);
+  addContactShadow(x, z, 2.1, 2.3, 0.6);
+}
+
+function craftHeadboard(g, x, z) {
+  const hb = new THREE.Mesh(new THREE.BoxGeometry(1.9, 1.0, 0.12), MAT.wood); hb.position.set(x, 0.9, z); hb.castShadow = true; g.add(hb);
+}
+
+function craftNightstand(g, x, z) {
+  const ns = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.5, 0.4), MAT.wood); ns.position.set(x, 0.25, z); ns.castShadow = ns.receiveShadow = true; g.add(ns);
+  // Small emissive lamp glow on top.
+  const lamp = new THREE.Mesh(new THREE.CylinderGeometry(0.09, 0.11, 0.16, 16), emissiveMat(0xffe6c0, 0.55)); lamp.position.set(x, 0.6, z); g.add(lamp);
+  addContactShadow(x, z, 0.6, 0.5, 0.5);
+}
+
+function craftDresser(g, x, z, rotY) {
+  const grp = new THREE.Group();
+  const body = new THREE.Mesh(new THREE.BoxGeometry(1.4, 0.85, 0.5), MAT.wood); body.position.y = 0.42; body.castShadow = body.receiveShadow = true; grp.add(body);
+  // Drawer seams.
+  for (let r = 0; r < 3; r++) { const d = new THREE.Mesh(new THREE.BoxGeometry(1.3, 0.24, 0.02), stdMat(0x59422e, 0.6, 0.0)); d.position.set(0, 0.16 + r * 0.26, 0.26); grp.add(d); }
+  grp.position.set(x, 0, z); grp.rotation.y = rotY; g.add(grp);
+}
+
+function craftRug(g, x, z, w, d, color, round, r) {
+  let mesh;
+  if (round) mesh = new THREE.Mesh(new THREE.CircleGeometry(r || 1.7, 48), stdMat(color, 1.0, 0.0));
+  else mesh = new THREE.Mesh(new THREE.PlaneGeometry(w, d), stdMat(color, 1.0, 0.0));
+  mesh.rotation.x = -PI / 2; mesh.position.set(x, 0.012, z); mesh.receiveShadow = true; g.add(mesh);
+}
+
+function craftDesk(g, x, z, rotY) {
+  const grp = new THREE.Group();
+  const top = new THREE.Mesh(new THREE.BoxGeometry(1.6, 0.05, 0.75), MAT.wood); top.position.set(0, 0.74, 0); top.castShadow = top.receiveShadow = true; grp.add(top);
+  [-0.72, 0.72].forEach(lx => { const leg = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.72, 0.68), MAT.wood); leg.position.set(lx, 0.37, 0); leg.castShadow = true; grp.add(leg); });
+  // Emissive monitor.
+  const mon = new THREE.Mesh(new THREE.PlaneGeometry(0.55, 0.34), new THREE.MeshBasicMaterial({ color: 0x1a2430 })); mon.position.set(0, 1.02, -0.18); grp.add(mon);
+  const stand = new THREE.Mesh(new THREE.BoxGeometry(0.06, 0.14, 0.06), MAT.dark); stand.position.set(0, 0.85, -0.18); grp.add(stand);
+  // Two swatch/paper boxes.
+  [[-0.5, 0.06], [0.55, 0.02]].forEach(([sx, sy]) => { const pb = new THREE.Mesh(new THREE.BoxGeometry(0.24, 0.03, 0.32), stdMat(0xe8e0cf, 0.9, 0.0)); pb.position.set(sx, 0.77 + sy, 0.05); pb.rotation.y = sx < 0 ? 0.2 : -0.15; grp.add(pb); });
+  grp.position.set(x, 0, z); grp.rotation.y = rotY; g.add(grp);
+  addContactShadow(x, z, 1.7, 0.9, 0.55);
+}
+
+function craftOfficeChair(g, x, z, rotY, tone) {
+  const grp = new THREE.Group();
+  const uph = stdMat(tone.soft, 0.75, 0.05);
+  // 5-star base.
+  const hub = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 0.05, 12), MAT.dark); hub.position.y = 0.04; grp.add(hub);
+  for (let i = 0; i < 5; i++) { const a = (i / 5) * PI * 2; const arm = new THREE.Mesh(new THREE.BoxGeometry(0.04, 0.03, 0.3), MAT.dark); arm.position.set(Math.cos(a) * 0.15, 0.03, Math.sin(a) * 0.15); arm.rotation.y = -a; grp.add(arm); const cw = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.03, 0.05, 8), MAT.dark); cw.rotation.z = PI / 2; cw.position.set(Math.cos(a) * 0.3, 0.03, Math.sin(a) * 0.3); grp.add(cw); }
+  const col = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.03, 0.42, 10), MAT.chrome); col.position.y = 0.28; grp.add(col);
+  const seat = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.1, 0.5), uph); seat.position.y = 0.52; seat.castShadow = true; grp.add(seat);
+  const back = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.6, 0.1), uph); back.position.set(0, 0.85, -0.22); back.castShadow = true; grp.add(back);
+  grp.position.set(x, 0, z); grp.rotation.y = rotY; g.add(grp);
+  addContactShadow(x, z, 0.7, 0.7, 0.5);
+}
+
+function craftArmchair(g, x, z, rotY) {
+  const grp = new THREE.Group();
+  const boucle = stdMat(0xe8e0d0, 0.95, 0.0), wood = stdMat(0x6e573a, 0.5, 0.0);
+  const seat = new THREE.Mesh(new THREE.BoxGeometry(0.6, 0.18, 0.56), boucle); seat.position.set(0, 0.44, 0); seat.castShadow = true; grp.add(seat);
+  const back = new THREE.Mesh(new THREE.BoxGeometry(0.6, 0.55, 0.16), boucle); back.position.set(0, 0.72, -0.22); back.castShadow = true; grp.add(back);
+  [-0.3, 0.3].forEach(ax => { const arm = new THREE.Mesh(new THREE.BoxGeometry(0.12, 0.24, 0.5), boucle); arm.position.set(ax, 0.56, 0); arm.castShadow = true; grp.add(arm); });
+  [[-0.22, 0.22], [0.22, 0.22], [-0.22, -0.22], [0.22, -0.22]].forEach(([lx, lz]) => { const leg = new THREE.Mesh(new THREE.CylinderGeometry(0.022, 0.016, 0.4, 8), wood); leg.position.set(lx, 0.2, lz); grp.add(leg); });
+  grp.position.set(x, 0, z); grp.rotation.y = rotY; g.add(grp);
+  addContactShadow(x, z, 0.8, 0.8, 0.5);
+}
+
+function craftCoffeeTable(g, x, z, r, wood) {
+  const mat = wood ? MAT.wood : new THREE.MeshStandardMaterial({ color: 0xcfc7b8, roughness: 0.4, metalness: 0.1, envMapIntensity: 0.6 });
+  const top = new THREE.Mesh(new THREE.CylinderGeometry(r || 0.5, r || 0.5, 0.08, 36), mat); top.position.set(x, 0.4, z); top.castShadow = top.receiveShadow = true; g.add(top);
+  const drum = new THREE.Mesh(new THREE.CylinderGeometry((r || 0.5) * 0.55, (r || 0.5) * 0.6, 0.36, 24), MAT.chrome); drum.position.set(x, 0.2, z); drum.castShadow = true; g.add(drum);
+  addContactShadow(x, z, (r || 0.5) * 2.2, (r || 0.5) * 2.2, 0.55);
+}
+
+function craftReception(g, x, z) {
+  const grp = new THREE.Group();
+  const front = new THREE.Mesh(new THREE.BoxGeometry(3.0, 1.05, 0.7), MAT.wood); front.position.set(0, 0.525, 0); front.castShadow = front.receiveShadow = true; grp.add(front);
+  const cap = new THREE.Mesh(new THREE.BoxGeometry(3.15, 0.1, 0.85), new THREE.MeshStandardMaterial({ color: 0xcfc7b8, roughness: 0.35, metalness: 0.1, envMapIntensity: 0.6 })); cap.position.set(0, 1.1, 0); cap.castShadow = true; grp.add(cap);
+  grp.position.set(x, 0, z); g.add(grp);
+  addContactShadow(x, z, 3.2, 0.9, 0.6);
+}
+
+function craftBench(g, x, z) {
+  const grp = new THREE.Group();
+  const slab = new THREE.Mesh(new THREE.BoxGeometry(1.6, 0.1, 0.45), stdMat(0x2f2c2a, 0.5, 0.05)); slab.position.set(0, 0.42, 0); slab.castShadow = slab.receiveShadow = true; grp.add(slab);
+  [-0.6, 0.6].forEach(lx => { const leg = new THREE.Mesh(new THREE.BoxGeometry(0.12, 0.42, 0.4), stdMat(0x25221f, 0.5, 0.05)); leg.position.set(lx, 0.21, 0); leg.castShadow = true; grp.add(leg); });
+  grp.position.set(x, 0, z); g.add(grp);
+  addContactShadow(x, z, 1.7, 0.5, 0.55);
+}
+
+function craftPedestal(g, x, z) {
+  const p = new THREE.Mesh(new THREE.BoxGeometry(0.4, 1.1, 0.4), stdMat(0xe8e4dc, 0.7, 0.0)); p.position.set(x, 0.55, z); p.castShadow = p.receiveShadow = true; g.add(p);
+  // A small turned sculptural object on top.
+  const obj = new THREE.Mesh(new THREE.IcosahedronGeometry(0.13, 0), stdMat(0xb9a88c, 0.6, 0.1)); obj.position.set(x, 1.22, z); obj.castShadow = true; g.add(obj);
+  addContactShadow(x, z, 0.5, 0.5, 0.5);
+}
+
+function craftFramedArt(g, x, y, z, rotY, imageUrl) {
+  const grp = new THREE.Group();
+  const frame = new THREE.Mesh(new THREE.BoxGeometry(0.72, 0.92, 0.04), MAT.frame); frame.castShadow = true; grp.add(frame);
+  const plane = new THREE.Mesh(new THREE.PlaneGeometry(0.62, 0.82), new THREE.MeshBasicMaterial({ color: 0xd8cfc0 }));
+  plane.position.z = 0.025; grp.add(plane);
+  if (imageUrl) {
+    const src = imageUrl.charAt(0) === '/' ? imageUrl : ('/api/proxy/image?url=' + encodeURIComponent(imageUrl));
+    new THREE.TextureLoader().load(src, t => { srgb(t); plane.material = new THREE.MeshBasicMaterial({ map: t }); plane.material.needsUpdate = true; }, undefined, () => {});
+  }
+  grp.position.set(x, y, z); grp.rotation.y = rotY; g.add(grp);
+}
+
+function craftWallLabel(g, x, y, z, text) {
+  const c = document.createElement('canvas'); c.width = 256; c.height = 96;
+  const ctx = c.getContext('2d'); ctx.fillStyle = '#f4efe6'; ctx.fillRect(0, 0, 256, 96);
+  ctx.fillStyle = '#1a1a1a'; ctx.font = 'bold 22px Georgia, serif'; ctx.textAlign = 'left'; ctx.textBaseline = 'top';
+  ctx.fillText((text || 'Pattern').slice(0, 22), 16, 20);
+  ctx.font = '15px Georgia, serif'; ctx.fillStyle = '#666'; ctx.fillText('Quadrille · China Seas', 16, 54);
+  const tex = new THREE.CanvasTexture(c);
+  const m = new THREE.Mesh(new THREE.PlaneGeometry(0.34, 0.13), new THREE.MeshBasicMaterial({ map: tex })); m.position.set(x, y, z); g.add(m);
+}
+
+// ---- CEILING FIXTURES (emissive primitive + optional co-located light) ----
+function fxPendant(g, H, D, tone) {
+  const x = 0, z = -D / 2 + 1.4, y = H - 0.55;
+  const stem = new THREE.Mesh(new THREE.CylinderGeometry(0.012, 0.012, 0.5, 8), MAT.chrome); stem.position.set(x, H - 0.28, z); g.add(stem);
+  const shade = new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.2, 0.22, 24), emissiveMat(0xffe6c0, 0.5)); shade.position.set(x, y, z); g.add(shade);
+  const pl = new THREE.PointLight(0xffcaa0, 0.6, 5); pl.position.set(x, y - 0.1, z); g.add(pl); roomTypeLights.push(pl);
+}
+function fxTrackRecessed(g, W, H, D) {
+  const glowTex = stripGlowTexture();
+  [-W * 0.22, W * 0.22].forEach(sx => {
+    const strip = new THREE.Mesh(new THREE.PlaneGeometry(0.1, D * 0.7), new THREE.MeshBasicMaterial({ color: 0xf6f8ff })); strip.rotation.x = PI / 2; strip.position.set(sx, H - 0.012, 0); g.add(strip);
+    const glow = new THREE.Mesh(new THREE.PlaneGeometry(0.5, D * 0.78), new THREE.MeshBasicMaterial({ map: glowTex, transparent: true, opacity: 0.5, blending: THREE.AdditiveBlending, depthWrite: false })); glow.rotation.x = PI / 2; glow.position.set(sx, H - 0.02, 0); glow.renderOrder = 3; g.add(glow);
+  });
+  // 3 emissive downlight discs over the desk.
+  [-0.5, 0, 0.5].forEach(dx => { const disc = new THREE.Mesh(new THREE.CircleGeometry(0.09, 20), new THREE.MeshBasicMaterial({ color: 0xf6f8ff })); disc.rotation.x = PI / 2; disc.position.set(dx, H - 0.014, -D / 2 + 1.1); g.add(disc); });
+  const pl = new THREE.PointLight(0xf6f8ff, 0.25, 6); pl.position.set(0, H - 0.4, -D / 2 + 1.1); g.add(pl); roomTypeLights.push(pl);
+}
+function fxChandelier(g, H, D) {
+  const cx = 0, cz = 0.2, cy = H - 1.1;
+  const stem = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 1.0, 10), MAT.chrome); stem.position.set(cx, H - 0.5, cz); g.add(stem);
+  const ring = new THREE.Mesh(new THREE.TorusGeometry(0.55, 0.03, 8, 32), MAT.chrome); ring.rotation.x = PI / 2; ring.position.set(cx, cy, cz); g.add(ring);
+  const ring2 = new THREE.Mesh(new THREE.TorusGeometry(0.32, 0.025, 8, 28), MAT.chrome); ring2.rotation.x = PI / 2; ring2.position.set(cx, cy - 0.28, cz); g.add(ring2);
+  const bulbMat = emissiveMat(0xffe6bd, 0.9);
+  for (let i = 0; i < 12; i++) { const a = (i / 12) * PI * 2; const r = i % 2 ? 0.32 : 0.55, yo = i % 2 ? -0.28 : 0; const b = new THREE.Mesh(new THREE.SphereGeometry(0.05, 12, 10), bulbMat); b.position.set(cx + Math.cos(a) * r, cy + yo - 0.06, cz + Math.sin(a) * r); g.add(b); }
+  const pl = new THREE.PointLight(0xffe6bd, 0.9, 10); pl.position.set(cx, cy - 0.2, cz); g.add(pl); roomTypeLights.push(pl);
+}
+function fxFlushMount(g, H) {
+  const dome = new THREE.Mesh(new THREE.SphereGeometry(0.22, 24, 12, 0, PI * 2, PI * 0.5, PI * 0.5), emissiveMat(0xffe6c0, 0.5)); dome.position.set(0, H - 0.18, 0); g.add(dome);
+  const ring = new THREE.Mesh(new THREE.TorusGeometry(0.23, 0.015, 6, 24), MAT.chrome); ring.rotation.x = PI / 2; ring.position.set(0, H - 0.16, 0); g.add(ring);
+}
+function fxTrackSpots(g, W, H, D, tone, spotColor) {
+  const railZ = -D / 2 + 1.4, railY = H - 0.12;
+  const rail = new THREE.Mesh(new THREE.BoxGeometry(W * 0.7, 0.05, 0.06), MAT.dark); rail.position.set(0, railY, railZ); g.add(rail);
+  const nHeads = 4;
+  for (let i = 0; i < nHeads; i++) {
+    const hx = (-(nHeads - 1) / 2 + i) * (W * 0.7 / nHeads);
+    const head = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.07, 0.16, 12), MAT.dark); head.position.set(hx, railY - 0.1, railZ); head.rotation.x = 0.5; g.add(head);
+    const spot = new THREE.SpotLight(spotColor || 0xffe6bd, 1.4, 9, PI / 7.5, 0.45, 1.2);
+    spot.position.set(hx, railY - 0.1, railZ);
+    spot.target.position.set(hx * 0.8, 1.5, -D / 2 + 0.05);
+    if (i === Math.floor(nHeads / 2)) { spot.castShadow = true; spot.shadow.mapSize.set(1024, 1024); spot.shadow.camera.near = 0.5; spot.shadow.camera.far = D; }
+    g.add(spot); g.add(spot.target); roomTypeLights.push(spot);
+  }
+}
+
+// ---- FURNITURE SETS ------------------------------------------------------
+// Each returns nothing; appends its pieces to roomTypeGroup (g). Positions in
+// the room-center frame for the type's own W/D. Also records hero-model swap
+// slots via `heroSlots` for GLTFLoader to fill.
+let heroSlots = [];  // { key, url, pos:[x,y,z], rot, scale, primitiveNodes:[Object3D] }
+
+function furnitureBedroom(g, W, D, H, tone) {
+  const backZ = -D / 2;
+  craftHeadboard(g, 0, backZ + 0.35);
+  const bedZ = backZ + 1.35;
+  const bedPieces = [];
+  const before = g.children.length;
+  craftBed(g, 0, bedZ, tone);
+  for (let i = before; i < g.children.length; i++) bedPieces.push(g.children[i]);
+  heroSlots.push({ key: 'bed', url: MODEL_URLS.bed, pos: [0, 0, bedZ], rot: 0, scale: null, nodes: bedPieces });
+  craftNightstand(g, -1.15, backZ + 0.55);
+  craftNightstand(g, 1.15, backZ + 0.55);
+  craftDresser(g, -W / 2 + 0.3, 0.4, PI / 2);
+  craftRug(g, 0, backZ + 2.6, 2.6, 1.8, tone.rug, false);
+}
+
+function furnitureOffice(g, W, D, H, tone) {
+  const backZ = -D / 2;
+  const deskPieces = []; const before = g.children.length;
+  craftDesk(g, 0, backZ + 1.1, 0);
+  for (let i = before; i < g.children.length; i++) deskPieces.push(g.children[i]);
+  heroSlots.push({ key: 'desk', url: MODEL_URLS.desk, pos: [0, 0, backZ + 1.1], rot: 0, scale: null, nodes: deskPieces });
+  const chairPieces = []; const cb = g.children.length;
+  craftOfficeChair(g, 0, backZ + 0.55, PI, tone);
+  for (let i = cb; i < g.children.length; i++) chairPieces.push(g.children[i]);
+  heroSlots.push({ key: 'office-chair', url: MODEL_URLS['office-chair'], pos: [0, 0, backZ + 0.55], rot: PI, scale: null, nodes: chairPieces });
+  buildBookShelfInto(g, W / 2 - 0.2, 0, -PI / 2, 2.4);
+  craftArmchair(g, W / 2 - 0.9, D / 2 - 1.2, 2.6);
+}
+
+function furnitureLobby(g, W, D, H, tone) {
+  const backZ = -D / 2;
+  craftReception(g, 0, backZ + 0.9);
+  const sofaAPieces = []; let before = g.children.length;
+  craftSofa(g, 0, 1.2, PI, tone);
+  for (let i = before; i < g.children.length; i++) sofaAPieces.push(g.children[i]);
+  heroSlots.push({ key: 'sofa', url: MODEL_URLS.sofa, pos: [0, 0, 1.2], rot: PI, scale: null, nodes: sofaAPieces });
+  const sofaBPieces = []; before = g.children.length;
+  craftSofa(g, 0, -1.2, 0, tone);
+  for (let i = before; i < g.children.length; i++) sofaBPieces.push(g.children[i]);
+  heroSlots.push({ key: 'sofa', url: MODEL_URLS.sofa, pos: [0, 0, -1.2], rot: 0, scale: null, nodes: sofaBPieces });
+  const ctPieces = []; before = g.children.length;
+  craftCoffeeTable(g, 0, 0, 0.6, false);
+  for (let i = before; i < g.children.length; i++) ctPieces.push(g.children[i]);
+  heroSlots.push({ key: 'coffee-table', url: MODEL_URLS['coffee-table'], pos: [0, 0, 0], rot: 0, scale: null, nodes: ctPieces });
+  buildOliveInto(g, -2.4, 0, backZ + 0.8);
+  buildOliveInto(g, 2.4, 0, backZ + 0.8);
+  craftRug(g, 0, 0, 4.0, 3.0, tone.rug, false);
+}
+
+function furnitureLiving(g, W, D, H, tone) {
+  const backZ = -D / 2;
+  const sofaPieces = []; let before = g.children.length;
+  craftSofa(g, 0, backZ + 0.78, 0, tone);
+  for (let i = before; i < g.children.length; i++) sofaPieces.push(g.children[i]);
+  heroSlots.push({ key: 'sofa', url: MODEL_URLS.sofa, pos: [0, 0, backZ + 0.78], rot: 0, scale: null, nodes: sofaPieces });
+  const ctPieces = []; before = g.children.length;
+  craftCoffeeTable(g, 0, backZ + 1.9, 0.5, true);
+  for (let i = before; i < g.children.length; i++) ctPieces.push(g.children[i]);
+  heroSlots.push({ key: 'coffee-table', url: MODEL_URLS['coffee-table'], pos: [0, 0, backZ + 1.9], rot: 0, scale: null, nodes: ctPieces });
+  craftRug(g, 0, backZ + 1.7, 0, 0, tone.rug, true, 1.7);
+  // Floor lamp (proto).
+  const pole = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 1.5, 12), stdMat(0x3a3026, 0.6, 0.1)); pole.position.set(W * 0.32, 0.75, -D * 0.3); g.add(pole);
+  const shade = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.24, 0.28, 20), emissiveMat(0xffe6c0, 0.6)); shade.position.set(W * 0.32, 1.5, -D * 0.3); g.add(shade);
+  const pl = new THREE.PointLight(0xffcaa0, 0.55, 9); pl.position.set(W * 0.32, 1.5, -D * 0.3); g.add(pl); roomTypeLights.push(pl);
+  craftArmchair(g, -W * 0.3, D * 0.2, 2.4);
+  buildOliveInto(g, -2.2, 0, backZ + 0.4);
+}
+
+function furnitureGallery(g, W, D, H, tone) {
+  const backZ = -D / 2;
+  craftBench(g, 0, 1.2); craftBench(g, 0, 2.2);
+  const p1 = []; let before = g.children.length;
+  craftPedestal(g, -2.0, -0.5);
+  for (let i = before; i < g.children.length; i++) p1.push(g.children[i]);
+  heroSlots.push({ key: 'pedestal', url: MODEL_URLS.pedestal, pos: [-2.0, 0, -0.5], rot: 0, scale: null, nodes: p1 });
+  craftPedestal(g, 2.0, -0.5);
+  // Two framed side pieces on the LEFT wall showing the pattern (gallery-of-collection).
+  const img = activeProductImage();
+  craftFramedArt(g, -W / 2 + 0.05, 1.5, -1.0, PI / 2, img);
+  craftFramedArt(g, -W / 2 + 0.05, 1.5, 1.0, PI / 2, img);
+  const pn = activeProductName();
+  craftWallLabel(g, 1.2, 1.4, backZ + 0.03, pn);
+}
+
+// buildBookShelf / buildOliveTree add straight to `scene`; these wrappers reparent
+// their created meshes into the room-type group so teardown removes them cleanly.
+function buildBookShelfInto(g, x, z, rot, unitW) {
+  const before = scene.children.length;
+  buildBookShelf(x, z, rot, unitW);
+  for (let i = scene.children.length - 1; i >= before; i--) { const c = scene.children[i]; scene.remove(c); g.add(c); }
+}
+function buildOliveInto(g, x, y, z) {
+  const before = scene.children.length;
+  buildOliveTree(x, y, z);
+  for (let i = scene.children.length - 1; i >= before; i--) { const c = scene.children[i]; scene.remove(c); g.add(c); }
+  addContactShadow(x, z, 0.6, 0.6, 0.8);
+}
+
+function activeProductImage() {
+  if (focusedWing && focusedWing.userData && focusedWing.userData.product) return focusedWing.userData.product.image;
+  if (centerBook && centerBook.product) return centerBook.product.image;
+  return null;
+}
+function activeProductName() {
+  if (focusedWing && focusedWing.userData && focusedWing.userData.product) return focusedWing.userData.product.pattern_name;
+  if (centerBook && centerBook.product) return centerBook.product.pattern_name;
+  return 'China Seas';
+}
+
+// ---- ROOM-TYPE APPLY / TEARDOWN ------------------------------------------
+function teardownRoomType() {
+  if (roomTypeGroup) {
+    roomTypeGroup.traverse(o => {
+      if (o.geometry && o.geometry.dispose) o.geometry.dispose();
+      if (o.material) { const mm = Array.isArray(o.material) ? o.material : [o.material]; mm.forEach(m => { if (m.map && m.map.dispose) m.map.dispose(); if (m.dispose) m.dispose(); }); }
+    });
+    scene.remove(roomTypeGroup);
+  }
+  roomTypeLights.forEach(l => { if (l.target) scene.remove(l.target); scene.remove(l); });
+  roomTypeLights = [];
+  roomTypeGroup = null;
+  heroSlots = [];
+}
+
+// Apply the light rig of a room type onto the existing lights (never creates new
+// ambient/hemi/key — retunes the ones buildLighting made, like THEMES does).
+function applyRoomTypeLights(rec) {
+  const L = rec.lights; if (!L) return;
+  const amb = scene.children.find(o => o.isAmbientLight);
+  const hemi = scene.children.find(o => o.isHemisphereLight);
+  const key = window._keyLight, pic = window._picLight;
+  // fill = a non-shadow directional; rim = the other non-shadow directional.
+  const dirs = scene.children.filter(o => o.isDirectionalLight && !o.castShadow);
+  if (amb && L.ambient) { amb.color.setHex(L.ambient[0]); amb.intensity = L.ambient[1]; }
+  if (hemi && L.hemi) { hemi.color.setHex(L.hemi[0]); if (hemi.groundColor) hemi.groundColor.setHex(L.hemi[1]); hemi.intensity = L.hemi[2]; }
+  if (key && L.key) { key.color.setHex(L.key.color); key.intensity = L.key.intensity; if ('radius' in key.shadow && L.key.radius) key.shadow.radius = L.key.radius; }
+  if (dirs[0] && L.fill) { dirs[0].color.setHex(L.fill[0]); dirs[0].intensity = L.fill[1]; }
+  if (dirs[1]) { if (L.rim) { dirs[1].color.setHex(L.rim[0]); dirs[1].intensity = L.rim[1]; } else dirs[1].intensity = 0.0; }
+  if (pic && typeof L.pic === 'number') pic.intensity = L.pic;
+  requestShadowUpdate(8);
+}
+
+// Set which of the room's walls are clad vs painted for this type. Painted walls
+// get a flat paint material (or keep MAT.wall limewash when paint===null).
+function applyRoomTypePaint(rec) {
+  const cladSet = new Set(rec.clad || ['back']);
+  const paintMat = (rec.paint == null) ? MAT.wall : stdMat(rec.paint, 0.95, 0.0);
+  roomWalls.forEach(w => {
+    if (cladSet.has(w.side)) {
+      // Clad walls keep their live clad material if a pattern is currently applied;
+      // else reset to the base wall mat now (so a wall that was painted near-black in
+      // the gallery reverts to plaster here) — the pattern re-clads on focus.
+      w.origMat = MAT.wall;
+      w.mesh.material = (w.cladMat && w.cladMat.map) ? w.cladMat : w.origMat;
+    } else {
+      w.origMat = paintMat;
+      w.mesh.material = paintMat;
+    }
+  });
+}
+
+// The main entry: swap the showroom into the chosen room type.
+function buildRoomType(key, opts) {
+  const rec = ROOM_TYPES[key]; if (!rec) return false;
+  opts = opts || {};
+  currentRoomType = key;
+  teardownRoomType();
+  roomTypeGroup = new THREE.Group(); roomTypeGroup.name = 'roomType:' + key;
+  scene.add(roomTypeGroup);
+
+  const W = CONFIG.room.width, D = CONFIG.room.depth, H = CONFIG.room.height;
+  const tone = activePaletteCtx();
+
+  // Floor material (respect a user floor override if the picker set one).
+  const floorKind = opts.floor || _userFloorOverride || rec.floor;
+  setFloorMaterial(floorKind);
+
+  // Paint / clad selection.
+  applyRoomTypePaint(rec);
+
+  // Ceiling color.
+  if (window._ceilingMesh && rec.ceiling != null && window._ceilingMesh.material.color) window._ceilingMesh.material.color.setHex(rec.ceiling);
+
+  // Snapshot scene children so we can sweep any scene-direct additions (contact
+  // shadows via addContactShadow) into the room-type group → teardown disposes them.
+  const _sceneSnap = scene.children.length;
+
+  // Ceiling fixture.
+  switch (rec.fixture) {
+    case 'pendant':         fxPendant(roomTypeGroup, H, D, tone); break;
+    case 'track-recessed':  fxTrackRecessed(roomTypeGroup, W, H, D); break;
+    case 'chandelier':      fxChandelier(roomTypeGroup, H, D); break;
+    case 'flush-mount':     fxFlushMount(roomTypeGroup, H); break;
+    case 'track-spots':     fxTrackSpots(roomTypeGroup, W, H, D, tone, _galleryCoolSpot() ? 0xfff4ec : 0xffe6bd); break;
+  }
+
+  // Furniture set.
+  switch (rec.furniture) {
+    case 'bedroom': furnitureBedroom(roomTypeGroup, W, D, H, tone); break;
+    case 'office':  furnitureOffice(roomTypeGroup, W, D, H, tone); break;
+    case 'lobby':   furnitureLobby(roomTypeGroup, W, D, H, tone); break;
+    case 'living':  furnitureLiving(roomTypeGroup, W, D, H, tone); break;
+    case 'gallery': furnitureGallery(roomTypeGroup, W, D, H, tone); break;
+  }
+
+  // Sweep any scene-direct meshes added during the furniture build (contact shadows)
+  // into the room-type group, EXCEPT the group itself, so teardown removes them.
+  for (let i = scene.children.length - 1; i >= _sceneSnap; i--) {
+    const c = scene.children[i];
+    if (c === roomTypeGroup) continue;
+    if (c.isLight) continue;               // fixture lights are tracked in roomTypeLights
+    scene.remove(c); roomTypeGroup.add(c);
+  }
+
+  // Lighting rig.
+  applyRoomTypeLights(rec);
+
+  // Static-shadow flags for the new furniture.
+  roomTypeGroup.traverse(o => { if (o.isMesh && o.geometry && o.geometry.type !== 'PlaneGeometry' && o.geometry.type !== 'CircleGeometry') { o.castShadow = true; o.receiveShadow = true; } });
+  requestShadowUpdate(20);
+
+  // Persist.
+  try { localStorage.setItem('qh_room_type', key); } catch (e) {}
+  window._activeRoomType = key;
+
+  // Attempt hero-GLB swaps for the active room (lazy; keeps primitive on failure).
+  loadHeroModelsForActive();
+
+  return true;
+}
+
+// Frame the type's default camera (used by the picker + on explicit request).
+function frameRoomType(key) {
+  const rec = ROOM_TYPES[key]; if (!rec || !rec.camera) return;
+  const D = CONFIG.room.depth;
+  const resolve = v => (typeof v === 'string') ? eval(v.replace(/D/g, D)) : v; // only 'D/2±n' expressions
+  const c = rec.camera;
+  const pos = new THREE.Vector3(resolve(c.pos[0]), c.pos[1], resolve(c.pos[2]));
+  const look = new THREE.Vector3(resolve(c.look[0]), c.look[1], resolve(c.look[2]));
+  if (typeof smoothCameraTo === 'function') { smoothCameraTo(pos, look, () => { if (typeof lockControls === 'function') lockControls(pos.clone(), look.clone()); }, c.fov); }
+}
+
+// ---- GLTFLoader (hero-model swap) ----------------------------------------
+// CC0 / public-domain GLB URLs. See public/models/CREDITS.md. Local copies live
+// under /models/; if a local copy is absent the loader simply fails and the
+// crafted primitive stays — NEVER ship a broken/unlicensed model.
+const MODEL_URLS = {
+  'bed':          '/models/bed.glb',
+  'sofa':         '/models/sofa.glb',
+  'desk':         '/models/desk.glb',
+  'office-chair': '/models/office-chair.glb',
+  'coffee-table': '/models/coffee-table.glb',
+  'pedestal':     '/models/pedestal.glb'
+};
+let _gltfLoader = null;
+function getGLTFLoader() {
+  if (_gltfLoader) return _gltfLoader;
+  if (!THREE.GLTFLoader) return null;
+  _gltfLoader = new THREE.GLTFLoader();
+  return _gltfLoader;
+}
+// Fit a loaded model group to a target bounding size (so CC0 models at arbitrary
+// scale sit correctly), center it on the primitive's footprint, and drop it on floor.
+function fitModel(obj, targetW, targetD) {
+  const box = new THREE.Box3().setFromObject(obj);
+  const size = new THREE.Vector3(); box.getSize(size);
+  if (size.x < 1e-4 || size.z < 1e-4) return;
+  const s = Math.min(targetW / size.x, targetD / size.z);
+  obj.scale.setScalar(s);
+  const box2 = new THREE.Box3().setFromObject(obj);
+  const c = new THREE.Vector3(); box2.getCenter(c);
+  obj.position.x -= c.x; obj.position.z -= c.z;
+  obj.position.y -= box2.min.y; // sit on floor
+  obj.traverse(o => { if (o.isMesh) { o.castShadow = true; o.receiveShadow = true; } });
+}
+const HERO_TARGET = { bed: [1.9, 2.1], sofa: [2.3, 1.0], desk: [1.7, 0.8], 'office-chair': [0.7, 0.7], 'coffee-table': [1.1, 1.1], pedestal: [0.45, 0.45] };
+function loadHeroModelsForActive() {
+  const loader = getGLTFLoader(); if (!loader) return; // GLTFLoader not present → all primitives
+  heroSlots.forEach(slot => {
+    if (!slot.url) return;
+    const done = (gltf) => {
+      try {
+        const model = (heroModelCache[slot.url] || gltf.scene).clone(true);
+        heroModelCache[slot.url] = gltf.scene;
+        const tw = (HERO_TARGET[slot.key] || [1, 1]);
+        fitModel(model, tw[0], tw[1]);
+        const wrap = new THREE.Group();
+        wrap.position.set(slot.pos[0], slot.pos[1], slot.pos[2]);
+        wrap.rotation.y = slot.rot || 0;
+        wrap.add(model);
+        // Hide the primitive nodes only once the real model is in.
+        slot.nodes.forEach(n => { n.visible = false; });
+        if (roomTypeGroup) roomTypeGroup.add(wrap);
+        window._heroModelsLoaded = (window._heroModelsLoaded || 0) + 1;
+        requestShadowUpdate(8);
+      } catch (e) { /* keep primitive */ }
+    };
+    if (heroModelCache[slot.url]) { done({ scene: heroModelCache[slot.url] }); return; }
+    try {
+      loader.load(slot.url, done, undefined, () => { /* load failed → primitive stays */ });
+    } catch (e) { /* primitive stays */ }
+  });
+}
+
+// User floor override (flooring picker). null = use the room type's default.
+let _userFloorOverride = (function () { const v = localStorage.getItem('qh_floor'); return (v === 'oak' || v === 'stone') ? v : null; })();
+function setFloorOverride(kind) {
+  _userFloorOverride = (kind === 'default') ? null : kind;
+  try { if (_userFloorOverride) localStorage.setItem('qh_floor', _userFloorOverride); else localStorage.removeItem('qh_floor'); } catch (e) {}
+  const use = _userFloorOverride || (ROOM_TYPES[currentRoomType] && ROOM_TYPES[currentRoomType].floor) || 'oak';
+  setFloorMaterial(use);
+}
+
+// ---- resizeRoom(w,d,h) — tear down + rebuild the room shell + wing arc -----
+// Disposes the old wall/floor/ceiling/furniture geometry+materials, rebuilds
+// buildRoom(), re-fits wing.arcRadius + camera.startPos.z to the new footprint,
+// rebuilds the wing wall + the active room type, and re-frames. Persists w/h.
+let _roomShellRefs = null; // captured on first resize so we can dispose prior shell
+function resizeRoom(w, d, h) {
+  w = Math.max(3.0, Math.min(14.0, w || CONFIG.room.width));
+  d = Math.max(3.0, Math.min(14.0, d || CONFIG.room.depth));
+  h = Math.max(2.2, Math.min(6.0, h || CONFIG.room.height));
+
+  // Tear down the room-type dressing first.
+  teardownRoomType();
+
+  // Remove + dispose the prior shell meshes (floor/ceiling/walls/baseboards/crown/
+  // strips/sign) — everything buildRoom() created. We identify them by the tagged
+  // refs (floorMesh/ceilingMesh) + roomWalls[], plus a sweep of the plane/box décor
+  // that buildRoom adds without refs. Simplest robust approach: snapshot scene
+  // children before/after a rebuild is not possible retroactively, so we remove the
+  // known shell nodes and any leftover décor tagged _shell.
+  disposeAndRemove(window._floorMesh); window._floorMesh = null;
+  disposeAndRemove(window._ceilingMesh); window._ceilingMesh = null;
+  roomWalls.forEach(rw => { disposeAndRemove(rw.mesh); if (rw.cladMat) { if (rw.cladMat.map) rw.cladMat.map.dispose(); rw.cladMat.dispose(); } });
+  roomWalls = [];
+  (window._shellDecor || []).forEach(disposeAndRemove);
+  window._shellDecor = [];
+
+  // Commit new geometry.
+  CONFIG.room.width = w; CONFIG.room.depth = d; CONFIG.room.height = h;
+  // Re-fit the wing arc + camera pull-back to the new footprint (spec: bigger room →
+  // larger arc radius; keep the eye a comfortable distance off the back wall).
+  CONFIG.wing.arcRadius = Math.max(2.6, Math.min(4.6, d * 0.52));
+  CONFIG.camera.startPos.z = Math.max(0.4, Math.min(2.0, d / 2 - 2.4));
+
+  // Rebuild the shell.
+  buildRoom();
+  // Re-fit the eye + walk box.
+  if (lockedSpinEye) { lockedSpinEye.set(0, 1.6, CONFIG.camera.startPos.z); if (camera) camera.position.copy(lockedSpinEye); applySpinPose(); }
+
+  // Rebuild the wing wall so board positions re-fit the new arc (if products loaded).
+  // rebuildWingWall() disposes the prior arc group first (no dup), then in BOOK_MODE
+  // we re-seat the center book so its spine re-fits the new room depth.
+  if (products && products.length) {
+    try {
+      rebuildWingWall();
+      if (BOOK_MODE) setCenterBook(typeof bookIndex === 'number' ? bookIndex : 0);
+    } catch (e) { /* wing rebuild best-effort */ }
+  }
+  enableStaticShadows();
+
+  // Re-dress the active (or default) room type into the new box.
+  buildRoomType(currentRoomType || 'living');
+
+  // Persist.
+  try { localStorage.setItem('qh_room_w', String(w)); localStorage.setItem('qh_room_h', String(h)); localStorage.setItem('qh_room_d', String(d)); } catch (e) {}
+  requestShadowUpdate(24);
+  window._roomDims = { w, d, h };
+  return { w, d, h, arcRadius: CONFIG.wing.arcRadius, camZ: CONFIG.camera.startPos.z };
+}
+function disposeAndRemove(o) {
+  if (!o) return;
+  if (o.geometry && o.geometry.dispose) o.geometry.dispose();
+  if (o.material) { const mm = Array.isArray(o.material) ? o.material : [o.material]; mm.forEach(m => { if (m && m.map && m.map.dispose) m.map.dispose(); if (m && m.dispose) m.dispose(); }); }
+  scene.remove(o);
+}
+
 // ============================================================
 // VIEW-MODE / THEME API — stable surface for public/js/viewmodes.js.
 // Keeps the view-mode + theme engine in its own module without re-plumbing
@@ -4209,6 +4988,17 @@ window._qh = {
       default:            return new THREE.Vector3(0, 1.2, 0);
     }
   },
+  // ---- ROOM TYPES (Phase 2) — 5 furnished presets + flooring + adjustable room.
+  ROOM_TYPES, ROOM_TYPE_ORDER,
+  buildRoomType,
+  frameRoomType,
+  get currentRoomType() { return currentRoomType; },
+  get roomTypeFurnitureCount() { return roomTypeGroup ? roomTypeGroup.children.length : 0; },
+  get heroModelsLoaded() { return window._heroModelsLoaded || 0; },
+  setFloorOverride,
+  get floorOverride() { return _userFloorOverride; },
+  resizeRoom,
+  get roomDims() { return { w: CONFIG.room.width, d: CONFIG.room.depth, h: CONFIG.room.height, arcRadius: CONFIG.wing.arcRadius }; },
   // A per-frame hook the view-mode engine installs (orbit/carousel/macro drift etc.)
   frameHook: null,
   // A SECOND per-frame hook for the version overlay (pin reprojection). Kept separate
diff --git a/public/js/viewmodes.js b/public/js/viewmodes.js
index 8a42c0f..f26d7c9 100644
--- a/public/js/viewmodes.js
+++ b/public/js/viewmodes.js
@@ -308,6 +308,27 @@ function boot() {
     try { localStorage.setItem('qh_theme', key); } catch (e) {}
   }
 
+  // ===========================================================================
+  // ROOM TYPES (Phase 2) — furnished preset chooser + flooring picker.
+  // ===========================================================================
+  let currentRoom = null;
+  function applyRoomType(key, opts) {
+    if (!QH.buildRoomType) return;
+    const ok = QH.buildRoomType(key, opts || {});
+    if (!ok) return;
+    currentRoom = key;
+    document.querySelectorAll('#vm-room .vm-chip').forEach(c => c.classList.toggle('active', c.dataset.room === key));
+    try { localStorage.setItem('qh_room_type', key); } catch (e) {}
+    // Re-frame the room's default camera unless we're mid-walk (respect free explore).
+    if (!(opts && opts.noFrame) && QH.frameRoomType) { try { QH.frameRoomType(key); } catch (e) {} }
+  }
+  function setFloor(val) {
+    if (QH.setFloorOverride) QH.setFloorOverride(val);
+    document.querySelectorAll('#vm-floor .vm-chip').forEach(c => c.classList.toggle('active', c.dataset.floor === val));
+  }
+  // Expose so the window-bar room-size sliders + tests can drive it.
+  window._roomType = { apply: applyRoomType, floor: setFloor, get current() { return currentRoom; } };
+
   // ===========================================================================
   // setMode — the single switcher. Instant + reversible.
   // ===========================================================================
@@ -388,6 +409,12 @@ function boot() {
         '<div class="vm-eyebrow">Theme</div>' +
         '<div id="vm-theme" class="vm-grid vm-grid-theme"></div>' +
       '</div>' +
+      '<div class="vm-section">' +
+        '<div class="vm-eyebrow">Room</div>' +
+        '<div id="vm-room" class="vm-grid vm-grid-theme"></div>' +
+        '<div class="vm-eyebrow" style="margin-top:8px">Flooring</div>' +
+        '<div id="vm-floor" class="vm-grid vm-grid-theme"></div>' +
+      '</div>' +
       '<div class="vm-section vm-perfrow">' +
         '<button id="vm-perf-btn" class="vm-perf-btn" title="Toggle performance readout">Perf</button>' +
         '<button id="vm-collapse" class="vm-perf-btn" title="Collapse / expand the panel">View &amp; Theme</button>' +
@@ -424,6 +451,28 @@ function boot() {
       tg.appendChild(b);
     });
 
+    // populate ROOM-TYPE chips (Phase 2) — copy the theme-chip UI. Chooses a furnished
+    // room preset and re-frames its default camera. Persisted (qh_room_type).
+    const rg = document.getElementById('vm-room');
+    const rOrder = (QH.ROOM_TYPE_ORDER || []);
+    rOrder.forEach(k => {
+      const rec = QH.ROOM_TYPES[k];
+      const b = document.createElement('button');
+      b.className = 'vm-chip'; b.dataset.room = k; b.textContent = rec.label;
+      b.title = rec.label + ' — ' + (rec.mood || '');
+      b.addEventListener('click', () => applyRoomType(k));
+      rg.appendChild(b);
+    });
+
+    // populate FLOORING picker — oak / stone / (room default). Persisted (qh_floor).
+    const fg = document.getElementById('vm-floor');
+    [['default', 'Default'], ['oak', 'Oak'], ['stone', 'Stone']].forEach(([val, lbl]) => {
+      const b = document.createElement('button');
+      b.className = 'vm-chip'; b.dataset.floor = val; b.textContent = lbl;
+      b.addEventListener('click', () => setFloor(val));
+      fg.appendChild(b);
+    });
+
     document.getElementById('vm-perf-btn').addEventListener('click', () => togglePerf());
     document.getElementById('vm-collapse').addEventListener('click', () => {
       wrap.classList.toggle('collapsed');
@@ -444,6 +493,17 @@ function boot() {
   // Perf toggle restore.
   if (localStorage.getItem('qh_perf') === '1') togglePerf(true); else togglePerf(false);
 
+  // Room-type restore (Phase 2). Default = Living Room (closest to the canonical box).
+  // Build the furnished room WITHOUT auto-re-framing on boot so the showroom's own
+  // walk/guided boot pose still owns the camera; the user re-frames by clicking a chip.
+  const savedRoom = localStorage.getItem('qh_room_type');
+  const bootRoom = (savedRoom && QH.ROOM_TYPES && QH.ROOM_TYPES[savedRoom]) ? savedRoom : 'living';
+  // Reflect the saved floor override on the picker.
+  const savedFloor = QH.floorOverride || 'default';
+  document.querySelectorAll('#vm-floor .vm-chip').forEach(c => c.classList.toggle('active', c.dataset.floor === savedFloor));
+  // Defer the room build a beat so products/center-book have a chance to load (palette hook).
+  setTimeout(() => { applyRoomType(bootRoom, { noFrame: true }); }, 900);
+
   // View: Hero is ALWAYS the boot view for a first-time load (locked rule). But if
   // the user previously picked a mode, restore it AFTER the guided default has
   // settled — except never auto-restore the free-camera modes on boot (they'd land
@@ -467,8 +527,11 @@ function boot() {
     set: setMode,
     theme: applyTheme,
     perf: togglePerf,
+    room: applyRoomType,
+    floor: setFloor,
     get current() { return currentMode; },
     get theme_() { return currentTheme; },
+    get room_() { return currentRoom; },
     MODES, THEMES, MODE_ORDER, THEME_ORDER
   };
 
diff --git a/public/models/CREDITS.md b/public/models/CREDITS.md
new file mode 100644
index 0000000..5e26c36
--- /dev/null
+++ b/public/models/CREDITS.md
@@ -0,0 +1,43 @@
+# Hero furniture models — sources & licenses
+
+Phase 2 hybrid furniture (DTD verdict C): the showroom builds **every** piece as a
+crafted THREE primitive first (ships fully offline), then lazy-loads these real GLB
+hero models over the matching primitive for the active room only. If a model fails to
+load or is missing, the primitive stays — nothing here is ever shipped broken or
+unlicensed.
+
+All models below are from the **KhronosGroup / glTF-Sample-Assets** repository
+(https://github.com/KhronosGroup/glTF-Sample-Assets), downloaded 2026-06-30.
+
+| Local file | Slot(s) | Source model | License | Attribution |
+|---|---|---|---|---|
+| `sofa.glb` | Living-room sofa, Lobby sofas | SheenWoodLeatherSofa | CC BY 4.0 (improvements) + CC0 1.0 (original) | © 2024 Darmstadt Graphics Group GmbH (improvements, Eric Chadwick); original © 2021 Fran Calvente, public domain (CC0) |
+| `office-chair.glb` | Office chair | SheenChair | CC0 1.0 Universal | © 2020 Wayfair, LLC — Eric Chadwick |
+
+Source URLs:
+- SheenWoodLeatherSofa: https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/SheenWoodLeatherSofa/glTF-Binary/SheenWoodLeatherSofa.glb
+- SheenChair: https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/SheenChair/glTF-Binary/SheenChair.glb
+
+License texts:
+- CC0 1.0: https://creativecommons.org/publicdomain/zero/1.0/legalcode
+- CC BY 4.0: https://creativecommons.org/licenses/by/4.0/legalcode
+
+## Pieces that stayed CRAFTED PRIMITIVES (no verified-license GLB sourced)
+
+The following room-type hero slots kept their upgraded crafted primitive because the
+CC0/CC-BY sample-asset set contains no matching furniture piece, and no other source
+could be verified as correctly-licensed within scope (the task forbids shipping
+unlicensed or unverified models):
+
+- **bed** (bedroom) — primitive: walnut platform + mattress + duvet + pillows + throw
+- **desk** (office) — primitive: walnut top + panel legs + emissive monitor + swatch boxes
+- **coffee-table** (living + lobby) — primitive: stone/walnut drum-base round table
+- **pedestal** (gallery) — primitive: stone plinth + turned sculptural object
+
+Bookshelf, olive planter, benches, reception desk, nightstands, dresser, armchair,
+rug, framed art, wall label, and all ceiling fixtures are crafted primitives by design
+(cheap, license-free, and matched to the spec).
+
+To add more hero GLBs later: drop a CC0/CC-BY `<slot>.glb` into this folder matching a
+key in `MODEL_URLS` (showroom.js) — `bed`, `desk`, `coffee-table`, `pedestal` — record
+its source + license here, and it will be lazy-loaded over the primitive automatically.
diff --git a/public/models/office-chair.glb b/public/models/office-chair.glb
new file mode 100644
index 0000000..6652347
Binary files /dev/null and b/public/models/office-chair.glb differ
diff --git a/public/models/sofa.glb b/public/models/sofa.glb
new file mode 100644
index 0000000..817b524
Binary files /dev/null and b/public/models/sofa.glb differ
diff --git a/public/showroom.html b/public/showroom.html
index b514df8..907cdb0 100644
--- a/public/showroom.html
+++ b/public/showroom.html
@@ -304,6 +304,17 @@
       <span id="density-wrap" title="Open angle of the resting middle board (45° = the boot hero rake)">
         <span>Open&deg;</span><input type="range" id="open-range" min="20" max="90" step="5" value="45"><span id="open-val">45&deg;</span>
       </span>
+      <!-- ADJUSTABLE ROOM (Phase 2) — Width / Height / Depth sliders. Tears down + rebuilds
+           the room shell + wing arc + active room-type furniture via resizeRoom(w,d,h). -->
+      <span id="density-wrap" title="Room width (metres)">
+        <span>W</span><input type="range" id="room-w-range" min="3" max="14" step="0.2" value="6.1"><span id="room-w-val">6.1m</span>
+      </span>
+      <span id="density-wrap" title="Room depth (metres)">
+        <span>D</span><input type="range" id="room-d-range" min="3" max="14" step="0.2" value="6.1"><span id="room-d-val">6.1m</span>
+      </span>
+      <span id="density-wrap" title="Room height (metres)">
+        <span>H</span><input type="range" id="room-h-range" min="2.2" max="6" step="0.1" value="2.9"><span id="room-h-val">2.9m</span>
+      </span>
     </div>
 
     <!-- NOW VIEWING navigator — museum media-player strip (shown only on focus).
@@ -399,6 +410,7 @@
 
   <script src="/js/three.min.js"></script>
   <script src="/js/OrbitControls.js"></script>
+  <script src="/js/GLTFLoader.js"></script>
   <script src="/js/rack.js"></script>
   <script src="/js/showroom.js"></script>
   <script src="/js/viewmodes.js"></script>
diff --git a/scripts/gitify-phase2.sh b/scripts/gitify-phase2.sh
new file mode 100644
index 0000000..8c62c26
--- /dev/null
+++ b/scripts/gitify-phase2.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Phase-2 gitify — LOCAL commits only, NO push, NO deploy.
+# git + node were blocked for the build agent by the sandbox classifier, so this
+# script exists for Steve to run the required gitify step. Three logical commits.
+set -e
+cd "$(dirname "$0")/.."
+export GIT_AUTHOR_EMAIL="steve@designerwallcoverings.com"
+export GIT_COMMITTER_EMAIL="steve@designerwallcoverings.com"
+export GIT_AUTHOR_NAME="Steve"
+export GIT_COMMITTER_NAME="Steve"
+
+# 1) ROOM_TYPES registry + 5 types (the registry + builders live in showroom.js).
+git add public/js/showroom.js
+git commit -q -m "showroom P2: ROOM_TYPES registry + 5 types (bedroom/office/lobby/living/gallery)"
+
+# 2) Hybrid furniture (crafted primitives + GLTFLoader + hero GLBs + credits).
+git add public/js/GLTFLoader.js public/models/sofa.glb public/models/office-chair.glb public/models/CREDITS.md public/showroom.html
+git commit -q -m "showroom P2: hybrid furniture — crafted primitives + GLTFLoader + 2 CC0/CC-BY hero GLBs (sofa, office-chair)"
+
+# 3) Pickers (room-type + flooring) + adjustable-room sliders + verify script.
+git add public/js/viewmodes.js scripts/verify-roomtypes.mjs scripts/gitify-phase2.sh scripts/glbcheck.cjs scripts/syntax-check.cjs
+git commit -q -m "showroom P2: room-type + flooring pickers + adjustable-room W/D/H sliders (resizeRoom)"
+
+echo "Done. Local commits:"
+git log --oneline -3
diff --git a/scripts/glbcheck.cjs b/scripts/glbcheck.cjs
new file mode 100644
index 0000000..d7e40fb
--- /dev/null
+++ b/scripts/glbcheck.cjs
@@ -0,0 +1,8 @@
+const fs = require('fs');
+const dir = require('path').join(__dirname, '..', 'public', 'models');
+const names = ['sofa', 'office-chair'];
+for (const n of names) {
+  const p = require('path').join(dir, n + '.glb');
+  const b = fs.readFileSync(p);
+  console.log(n, 'magic:', b.slice(0, 4).toString('ascii'), 'ver:', b.readUInt32LE(4), 'declaredLen:', b.readUInt32LE(8), 'fileLen:', b.length);
+}
diff --git a/scripts/syntax-check.cjs b/scripts/syntax-check.cjs
new file mode 100644
index 0000000..38ea725
--- /dev/null
+++ b/scripts/syntax-check.cjs
@@ -0,0 +1,18 @@
+// Parse-only syntax check for the browser JS bundles (no DOM/THREE needed — we just
+// compile the source to catch syntax errors).
+const fs = require('fs');
+const path = require('path');
+const vm = require('vm');
+const files = ['public/js/showroom.js', 'public/js/viewmodes.js'];
+let ok = true;
+for (const f of files) {
+  const src = fs.readFileSync(path.join(__dirname, '..', f), 'utf8');
+  try {
+    new vm.Script(src, { filename: f });
+    console.log('OK   ', f);
+  } catch (e) {
+    ok = false;
+    console.log('FAIL ', f, '->', e.message);
+  }
+}
+process.exit(ok ? 0 : 1);
diff --git a/scripts/verify-roomtypes.mjs b/scripts/verify-roomtypes.mjs
new file mode 100644
index 0000000..db1c3b8
--- /dev/null
+++ b/scripts/verify-roomtypes.mjs
@@ -0,0 +1,90 @@
+// Phase-2 headless verification (playwright). Loads the showroom, asserts 0
+// pageerrors / console-errors (ignoring SwiftShader / GL_ / GPU-stall noise),
+// switches through all 5 room types, exercises the flooring picker + resizeRoom,
+// and asserts furniture is present each time. Saves recordings/roomtype-<type>.png.
+//
+// RUN (server must be up on :7690):
+//   node scripts/verify-roomtypes.mjs
+//
+// playwright is installed globally at ~/.npm-global/lib/node_modules/playwright.
+import { createRequire } from 'module';
+const require = createRequire('/Users/stevestudio2/.npm-global/lib/node_modules/');
+const { chromium } = require('playwright');
+import fs from 'fs';
+import path from 'path';
+import { fileURLToPath } from 'url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const REC = path.join(__dirname, '..', 'recordings');
+const URL = process.env.URL || 'http://127.0.0.1:7690/';
+const IGNORE = /SwiftShader|GL_|GPU stall|WebGL|Automatic fallback|software rendering|THREE\.WebGLRenderer|Text run|deprecat/i;
+
+const errors = [];
+(async () => {
+  const browser = await chromium.launch({ args: ['--use-gl=swiftshader', '--ignore-gpu-blocklist', '--enable-webgl'] });
+  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+  page.on('pageerror', e => errors.push('PAGEERROR: ' + e.message));
+  page.on('console', m => { if (m.type() === 'error' && !IGNORE.test(m.text())) errors.push('CONSOLE: ' + m.text()); });
+
+  console.log('→ loading', URL);
+  await page.goto(URL, { waitUntil: 'networkidle', timeout: 45000 });
+  // Wait for the _qh API + room-type engine to be live.
+  await page.waitForFunction(() => window._qh && window._qh.ROOM_TYPES && window._qh.buildRoomType, { timeout: 30000 });
+  // Let products + the deferred room-type build settle.
+  await page.waitForTimeout(3500);
+
+  const types = await page.evaluate(() => window._qh.ROOM_TYPE_ORDER.slice());
+  console.log('→ room types:', types.join(', '));
+
+  const results = [];
+  for (const t of types) {
+    const info = await page.evaluate((k) => {
+      window._qh.buildRoomType(k);
+      return { type: k, furniture: window._qh.roomTypeFurnitureCount, current: window._qh.currentRoomType, hero: window._qh.heroModelsLoaded };
+    }, t);
+    await page.waitForTimeout(1400); // allow GLB lazy-load + frame
+    const shot = path.join(REC, `roomtype-${t}.png`);
+    await page.screenshot({ path: shot });
+    info.furnitureAfterWait = await page.evaluate(() => window._qh.roomTypeFurnitureCount);
+    info.heroAfterWait = await page.evaluate(() => window._qh.heroModelsLoaded);
+    console.log(`   ${t}: furniture=${info.furnitureAfterWait} hero=${info.heroAfterWait} → ${path.basename(shot)}`);
+    results.push(info);
+  }
+
+  // Flooring picker.
+  const floorTest = await page.evaluate(() => {
+    const before = window._qh.floorOverride;
+    window._qh.setFloorOverride('stone');
+    const stone = window._qh.floorOverride;
+    window._qh.setFloorOverride('oak');
+    const oak = window._qh.floorOverride;
+    window._qh.setFloorOverride('default');
+    return { before, stone, oak, reset: window._qh.floorOverride };
+  });
+  console.log('→ flooring:', JSON.stringify(floorTest));
+
+  // resizeRoom.
+  const resizeTest = await page.evaluate(() => {
+    const r1 = window._qh.resizeRoom(8, 8, 4.2);
+    return { r1, furniture: window._qh.roomTypeFurnitureCount, dims: window._qh.roomDims };
+  });
+  await page.waitForTimeout(1500);
+  await page.screenshot({ path: path.join(REC, 'roomtype-resized-8x8.png') });
+  const resizeFurniture = await page.evaluate(() => window._qh.roomTypeFurnitureCount);
+  console.log('→ resizeRoom(8,8,4.2):', JSON.stringify(resizeTest.r1), 'furniture=', resizeFurniture);
+
+  // Resize back to default.
+  await page.evaluate(() => window._qh.resizeRoom(6.1, 6.1, 2.9));
+  await page.waitForTimeout(1200);
+
+  await browser.close();
+
+  console.log('\n========== SUMMARY ==========');
+  console.log('errors:', errors.length);
+  errors.forEach(e => console.log('  ' + e));
+  const allFurnished = results.every(r => r.furnitureAfterWait > 0) && resizeFurniture > 0;
+  console.log('every room type furnished:', allFurnished);
+  console.log('resize furnished:', resizeFurniture > 0);
+  console.log('screenshots saved to recordings/roomtype-*.png');
+  process.exit(errors.length === 0 && allFurnished ? 0 : 1);
+})().catch(e => { console.error('VERIFY FAILED:', e); process.exit(2); });

← bc32b4a showroom P1: remove angled/orbit/topdown, boot=walk-through-  ·  back to Quadrille Showroom  ·  showroom P2: 5 room types (bedroom/office/living/lobby/galle 5388cf1 →