<commit_before>/**
 * The GLTF behavior loads and displays a glTF model asset.
 *
 * @class GLTF
 * @param {Object} [config] Optional parameters.
 * @param {String} [config.url] A URL to the GLTF model file to be loaded.
 * @param {Number} [config.sceneIndex=0] Specifies the scene to load when the GLTF model contains multiple scenes.
 * @param {Boolean} [config.native=true] Specifies whether a native glTF (n-gltf) component will be used when running the app in the Altspace client.
 * @memberof module:altspaceutil/behaviors
 **/
altspaceutil.behaviors.GLTF = class {
	get type() { return 'GLTF'; }

	constructor(config) {
		this.config = Object.assign({ url: '', sceneIndex: 0, native: true }, config);
		this.url = this.config.url;
		this.sceneIndex = this.config.sceneIndex;
		this.loading = false;
		this.loaded = false;
	}

	awake(o, s) {
		this.object3d = o;

		altspaceutil.manageBehavior(this, this.object3d);

		if(this.config.native && altspace.inClient) {
			this.nativeComponent = new altspaceutil.behaviors.NativeComponent('n-gltf', { url: this.config.url, sceneIndex: this.config.sceneIndex });
			this.object3d.addEventListener('n-gltf-loaded', () => {
				this.loaded = this.nativeComponent.getAttribute('loaded');
				this.object3d.dispatchEvent({
					type: 'gltf-loaded',
					bubbles: true,
					target: this.object3d
				});
			});
			this.object3d.addBehavior(this.nativeComponent);
		} else {
			this.inverseWorldTransform = new THREE.Matrix4();
			this.localTransform = new THREE.Matrix4();
			this._loadMesh();
		}
	}

	update() {
		if(this.config.native && altspace.inClient) {
			this.loaded = this.nativeComponent.getAttribute('loaded');
			this.nativeComponent.data.url = this.config.url;
			this.nativeComponent.data.sceneIndex = this.config.sceneIndex;
		} else {
			if((this.config.url !== this.url || this.config.sceneIndex !== this.sceneIndex) && !this.loading) this._loadMesh();
		}
	}

	getBoundingBox() {
		if(this.config.native && altspace.inClient && this.nativeComponent) return this.nativeComponent.callComponentFunc('GetBoundingBox');
		if(!this.mesh || !this.loaded) return Promise.reject();

		this.object3d.updateMatrixWorld(true);
		this.inverseWorldTransform.getInverse(this.object3d.matrixWorld);
		this.mesh.applyMatrix(this.inverseWorldTransform);

		let bbox = new THREE.Box3().setFromObject(this.mesh);

		this.inverseWorldTransform.getInverse(this.inverseWorldTransform);
		this.mesh.applyMatrix(this.inverseWorldTransform);

		return Promise.resolve(bbox);
	}<commit_msg>Removed unused Matrix4 object from GLTF behavior.<commit_after>/**
 * The GLTF behavior loads and displays a glTF model asset.
 *
 * @class GLTF
 * @param {Object} [config] Optional parameters.
 * @param {String} [config.url] A URL to the GLTF model file to be loaded.
 * @param {Number} [config.sceneIndex=0] Specifies the scene to load when the GLTF model contains multiple scenes.
 * @param {Boolean} [config.native=true] Specifies whether a native glTF (n-gltf) component will be used when running the app in the Altspace client.
 * @memberof module:altspaceutil/behaviors
 **/
altspaceutil.behaviors.GLTF = class {
	get type() { return 'GLTF'; }

	constructor(config) {
		this.config = Object.assign({ url: '', sceneIndex: 0, native: true }, config);
		this.url = this.config.url;
		this.sceneIndex = this.config.sceneIndex;
		this.loading = false;
		this.loaded = false;
	}

	awake(o, s) {
		this.object3d = o;

		altspaceutil.manageBehavior(this, this.object3d);

		if(this.config.native && altspace.inClient) {
			this.nativeComponent = new altspaceutil.behaviors.NativeComponent('n-gltf', { url: this.config.url, sceneIndex: this.config.sceneIndex });
			this.object3d.addEventListener('n-gltf-loaded', () => {
				this.loaded = this.nativeComponent.getAttribute('loaded');
				this.object3d.dispatchEvent({
					type: 'gltf-loaded',
					bubbles: true,
					target: this.object3d
				});
			});
			this.object3d.addBehavior(this.nativeComponent);
		} else {
			this.inverseWorldTransform = new THREE.Matrix4();
			this._loadMesh();
		}
	}

	update() {
		if(this.config.native && altspace.inClient) {
			this.loaded = this.nativeComponent.getAttribute('loaded');
			this.nativeComponent.data.url = this.config.url;
			this.nativeComponent.data.sceneIndex = this.config.sceneIndex;
		} else {
			if((this.config.url !== this.url || this.config.sceneIndex !== this.sceneIndex) && !this.loading) this._loadMesh();
		}
	}

	getBoundingBox() {
		if(this.config.native && altspace.inClient && this.nativeComponent) return this.nativeComponent.callComponentFunc('GetBoundingBox');
		if(!this.mesh || !this.loaded) return Promise.reject();

		this.object3d.updateMatrixWorld(true);
		this.inverseWorldTransform.getInverse(this.object3d.matrixWorld);
		this.mesh.applyMatrix(this.inverseWorldTransform);

		let bbox = new THREE.Box3().setFromObject(this.mesh);

		this.inverseWorldTransform.getInverse(this.inverseWorldTransform);
		this.mesh.applyMatrix(this.inverseWorldTransform);

		return Promise.resolve(bbox);
	}
{'fraction_non_alphanumeric': 0.13728209191759114, 'fraction_numerical': 0.005150554675118859, 'mean_word_length': 4.446601941747573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3452682', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1589, 'n_words': 329}