@google/model-viewer
Advanced tools
Comparing version 2.0.0-rc1 to 2.0.0-rc2
@@ -10,3 +10,2 @@ export declare const HAS_WEBXR_DEVICE_API: boolean; | ||
export declare const IS_IOS: boolean; | ||
export declare const IS_AR_QUICKLOOK_CANDIDATE: boolean; | ||
export declare const IS_SAFARI: boolean; | ||
@@ -18,1 +17,8 @@ export declare const IS_FIREFOX: boolean; | ||
export declare const IS_SCENEVIEWER_CANDIDATE: boolean; | ||
declare global { | ||
interface Window { | ||
webkit?: any; | ||
} | ||
} | ||
export declare const IS_WKWEBVIEW: boolean; | ||
export declare const IS_AR_QUICKLOOK_CANDIDATE: boolean; |
@@ -52,7 +52,2 @@ /* @license | ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); | ||
export const IS_AR_QUICKLOOK_CANDIDATE = (() => { | ||
const tempAnchor = document.createElement('a'); | ||
return Boolean(tempAnchor.relList && tempAnchor.relList.supports && | ||
tempAnchor.relList.supports('ar')); | ||
})(); | ||
// @see https://developer.chrome.com/multidevice/user-agent | ||
@@ -65,2 +60,21 @@ export const IS_SAFARI = /Safari\//.test(navigator.userAgent); | ||
export const IS_SCENEVIEWER_CANDIDATE = IS_ANDROID && !IS_FIREFOX && !IS_OCULUS; | ||
export const IS_WKWEBVIEW = Boolean(window.webkit && window.webkit.messageHandlers); | ||
// If running in iOS Safari proper, and not within a WKWebView component instance, check for ARQL feature support. | ||
// Otherwise, if running in a WKWebView instance, check for known ARQL compatible iOS browsers, including: | ||
// Chrome (CriOS), Edge (EdgiOS), Firefox (FxiOS), Google App (GSA), DuckDuckGo (DuckDuckGo). | ||
// All other iOS browsers / apps will fail by default. | ||
export const IS_AR_QUICKLOOK_CANDIDATE = (() => { | ||
if (IS_IOS) { | ||
if (!IS_WKWEBVIEW) { | ||
const tempAnchor = document.createElement('a'); | ||
return Boolean(tempAnchor.relList && tempAnchor.relList.supports && tempAnchor.relList.supports('ar')); | ||
} | ||
else { | ||
return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent)); | ||
} | ||
} | ||
else { | ||
return false; | ||
} | ||
})(); | ||
//# sourceMappingURL=constants.js.map |
@@ -70,2 +70,4 @@ /* @license | ||
setup(async () => { | ||
// The shadow is here to expose an earlier bug on unloading models. | ||
element.shadowIntensity = 1; | ||
element.src = CUBE_GLB_PATH; | ||
@@ -99,2 +101,17 @@ await waitForEvent(element, 'poster-dismissed'); | ||
}); | ||
test('models are unloaded after src updates', async () => { | ||
element.src = HORSE_GLB_PATH; | ||
await waitForEvent(element, 'load'); | ||
const { shadow, model, target } = element[$scene]; | ||
const { children } = target; | ||
expect(children.length).to.be.eq(2, 'horse'); | ||
expect(children).to.contain(shadow, 'horse shadow'); | ||
expect(children).to.contain(model, 'horse model'); | ||
element.src = CUBE_GLB_PATH; | ||
await waitForEvent(element, 'load'); | ||
const { children: children2 } = target; | ||
expect(children2.length).to.be.eq(2, 'cube'); | ||
expect(children2).to.contain(shadow, 'cube shadow'); | ||
expect(children2).to.contain(element[$scene].model, 'cube model'); | ||
}); | ||
test('generates 3DModel schema', async () => { | ||
@@ -101,0 +118,0 @@ element.generateSchema = true; |
@@ -213,9 +213,9 @@ /* @license | ||
this.bakedShadows.clear(); | ||
this._model = null; | ||
const { _model } = this; | ||
if (_model != null) { | ||
_model.removeFromParent(); | ||
this._model = null; | ||
} | ||
const gltf = this._currentGLTF; | ||
// Remove all current children | ||
if (gltf != null) { | ||
for (const child of this.target.children) { | ||
this.target.remove(child); | ||
} | ||
gltf.dispose(); | ||
@@ -222,0 +222,0 @@ this._currentGLTF = null; |
{ | ||
"name": "@google/model-viewer", | ||
"version": "2.0.0-rc1", | ||
"version": "2.0.0-rc2", | ||
"description": "Easily display interactive 3D models on the web and in AR!", | ||
@@ -37,2 +37,4 @@ "repository": "https://github.com/google/model-viewer", | ||
], | ||
"typings": "dist/model-viewer.d.ts", | ||
"types": "dist/model-viewer.d.ts", | ||
"scripts": { | ||
@@ -39,0 +41,0 @@ "clean": "rm -rf ./lib ./dist", |
@@ -64,10 +64,2 @@ /* @license | ||
export const IS_AR_QUICKLOOK_CANDIDATE = (() => { | ||
const tempAnchor = document.createElement('a'); | ||
return Boolean( | ||
tempAnchor.relList && tempAnchor.relList.supports && | ||
tempAnchor.relList.supports('ar')); | ||
})(); | ||
// @see https://developer.chrome.com/multidevice/user-agent | ||
@@ -81,1 +73,28 @@ export const IS_SAFARI = /Safari\//.test(navigator.userAgent); | ||
export const IS_SCENEVIEWER_CANDIDATE = IS_ANDROID && !IS_FIREFOX && !IS_OCULUS; | ||
// Extend Window type with webkit property, | ||
// required to check if iOS is running within a WKWebView browser instance. | ||
declare global { | ||
interface Window { | ||
webkit?: any; | ||
} | ||
} | ||
export const IS_WKWEBVIEW = Boolean(window.webkit && window.webkit.messageHandlers); | ||
// If running in iOS Safari proper, and not within a WKWebView component instance, check for ARQL feature support. | ||
// Otherwise, if running in a WKWebView instance, check for known ARQL compatible iOS browsers, including: | ||
// Chrome (CriOS), Edge (EdgiOS), Firefox (FxiOS), Google App (GSA), DuckDuckGo (DuckDuckGo). | ||
// All other iOS browsers / apps will fail by default. | ||
export const IS_AR_QUICKLOOK_CANDIDATE = (() => { | ||
if(IS_IOS){ | ||
if(!IS_WKWEBVIEW){ | ||
const tempAnchor = document.createElement('a'); | ||
return Boolean(tempAnchor.relList && tempAnchor.relList.supports && tempAnchor.relList.supports('ar')); | ||
} else { | ||
return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent)); | ||
} | ||
} else { | ||
return false; | ||
} | ||
})(); |
@@ -87,2 +87,4 @@ /* @license | ||
setup(async () => { | ||
// The shadow is here to expose an earlier bug on unloading models. | ||
element.shadowIntensity = 1; | ||
element.src = CUBE_GLB_PATH; | ||
@@ -125,2 +127,20 @@ await waitForEvent(element, 'poster-dismissed'); | ||
test('models are unloaded after src updates', async () => { | ||
element.src = HORSE_GLB_PATH; | ||
await waitForEvent(element, 'load'); | ||
const {shadow, model, target} = element[$scene]; | ||
const {children} = target; | ||
expect(children.length).to.be.eq(2, 'horse'); | ||
expect(children).to.contain(shadow, 'horse shadow'); | ||
expect(children).to.contain(model, 'horse model'); | ||
element.src = CUBE_GLB_PATH; | ||
await waitForEvent(element, 'load'); | ||
const {children: children2} = target; | ||
expect(children2.length).to.be.eq(2, 'cube'); | ||
expect(children2).to.contain(shadow, 'cube shadow'); | ||
expect(children2).to.contain(element[$scene].model, 'cube model'); | ||
}); | ||
test('generates 3DModel schema', async () => { | ||
@@ -127,0 +147,0 @@ element.generateSchema = true; |
@@ -286,9 +286,10 @@ /* @license | ||
this._model = null; | ||
const {_model} = this; | ||
if (_model != null) { | ||
_model.removeFromParent(); | ||
this._model = null; | ||
} | ||
const gltf = this._currentGLTF; | ||
// Remove all current children | ||
if (gltf != null) { | ||
for (const child of this.target.children) { | ||
this.target.remove(child); | ||
} | ||
gltf.dispose(); | ||
@@ -295,0 +296,0 @@ this._currentGLTF = null; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21058053
125542