|
@@ -55,8 +55,9 @@ export class Inspector {
|
|
for (var index = 0; index < sourceDoc.styleSheets.length; index++) {
|
|
for (var index = 0; index < sourceDoc.styleSheets.length; index++) {
|
|
var styleSheet: any = sourceDoc.styleSheets[index];
|
|
var styleSheet: any = sourceDoc.styleSheets[index];
|
|
try {
|
|
try {
|
|
- if (styleSheet.cssRules) { // for <style> elements
|
|
|
|
- const newStyleEl = sourceDoc.createElement('style');
|
|
|
|
|
|
+ if (styleSheet.cssRules) {
|
|
|
|
+ // for <style> elements
|
|
|
|
+ const newStyleEl = sourceDoc.createElement("style");
|
|
|
|
|
|
for (var cssRule of styleSheet.cssRules) {
|
|
for (var cssRule of styleSheet.cssRules) {
|
|
// write the text of each rule into the body of the style element
|
|
// write the text of each rule into the body of the style element
|
|
@@ -64,17 +65,17 @@ export class Inspector {
|
|
}
|
|
}
|
|
|
|
|
|
targetDoc.head!.appendChild(newStyleEl);
|
|
targetDoc.head!.appendChild(newStyleEl);
|
|
- } else if (styleSheet.href) { // for <link> elements loading CSS from a URL
|
|
|
|
- const newLinkEl = sourceDoc.createElement('link');
|
|
|
|
|
|
+ } else if (styleSheet.href) {
|
|
|
|
+ // for <link> elements loading CSS from a URL
|
|
|
|
+ const newLinkEl = sourceDoc.createElement("link");
|
|
|
|
|
|
- newLinkEl.rel = 'stylesheet';
|
|
|
|
|
|
+ newLinkEl.rel = "stylesheet";
|
|
newLinkEl.href = styleSheet.href;
|
|
newLinkEl.href = styleSheet.href;
|
|
targetDoc.head!.appendChild(newLinkEl);
|
|
targetDoc.head!.appendChild(newLinkEl);
|
|
}
|
|
}
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e);
|
|
console.log(e);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,7 +92,7 @@ export class Inspector {
|
|
handleResize: options.handleResize,
|
|
handleResize: options.handleResize,
|
|
enablePopup: options.enablePopup,
|
|
enablePopup: options.enablePopup,
|
|
enableClose: options.enableClose,
|
|
enableClose: options.enableClose,
|
|
- explorerExtensibility: options.explorerExtensibility
|
|
|
|
|
|
+ explorerExtensibility: options.explorerExtensibility,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -117,10 +118,13 @@ export class Inspector {
|
|
if (this._SceneExplorerHost) {
|
|
if (this._SceneExplorerHost) {
|
|
this._OpenedPane++;
|
|
this._OpenedPane++;
|
|
const sceneExplorerElement = React.createElement(SceneExplorerComponent, {
|
|
const sceneExplorerElement = React.createElement(SceneExplorerComponent, {
|
|
- scene, globalState: this._GlobalState,
|
|
|
|
|
|
+ scene,
|
|
|
|
+ globalState: this._GlobalState,
|
|
extensibilityGroups: options.explorerExtensibility,
|
|
extensibilityGroups: options.explorerExtensibility,
|
|
noClose: !options.enableClose,
|
|
noClose: !options.enableClose,
|
|
- noExpand: !options.enablePopup, popupMode: options.popup, onPopup: () => {
|
|
|
|
|
|
+ noExpand: !options.enablePopup,
|
|
|
|
+ popupMode: options.popup,
|
|
|
|
+ onPopup: () => {
|
|
ReactDOM.unmountComponentAtNode(this._SceneExplorerHost!);
|
|
ReactDOM.unmountComponentAtNode(this._SceneExplorerHost!);
|
|
|
|
|
|
this._RemoveElementFromDOM(this._SceneExplorerHost);
|
|
this._RemoveElementFromDOM(this._SceneExplorerHost);
|
|
@@ -134,7 +138,8 @@ export class Inspector {
|
|
options.showInspector = false;
|
|
options.showInspector = false;
|
|
options.explorerWidth = options.popup ? "100%" : "300px";
|
|
options.explorerWidth = options.popup ? "100%" : "300px";
|
|
Inspector.Show(scene, options);
|
|
Inspector.Show(scene, options);
|
|
- }, onClose: () => {
|
|
|
|
|
|
+ },
|
|
|
|
+ onClose: () => {
|
|
ReactDOM.unmountComponentAtNode(this._SceneExplorerHost!);
|
|
ReactDOM.unmountComponentAtNode(this._SceneExplorerHost!);
|
|
Inspector._OpenedPane--;
|
|
Inspector._OpenedPane--;
|
|
|
|
|
|
@@ -145,7 +150,7 @@ export class Inspector {
|
|
if (options.popup) {
|
|
if (options.popup) {
|
|
this._SceneExplorerWindow.close();
|
|
this._SceneExplorerWindow.close();
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
});
|
|
});
|
|
ReactDOM.render(sceneExplorerElement, this._SceneExplorerHost);
|
|
ReactDOM.render(sceneExplorerElement, this._SceneExplorerHost);
|
|
}
|
|
}
|
|
@@ -173,9 +178,12 @@ export class Inspector {
|
|
if (this._ActionTabsHost) {
|
|
if (this._ActionTabsHost) {
|
|
this._OpenedPane++;
|
|
this._OpenedPane++;
|
|
const actionTabsElement = React.createElement(ActionTabsComponent, {
|
|
const actionTabsElement = React.createElement(ActionTabsComponent, {
|
|
- globalState: this._GlobalState, scene: scene,
|
|
|
|
|
|
+ globalState: this._GlobalState,
|
|
|
|
+ scene: scene,
|
|
noClose: !options.enableClose,
|
|
noClose: !options.enableClose,
|
|
- noExpand: !options.enablePopup, popupMode: options.popup, onPopup: () => {
|
|
|
|
|
|
+ noExpand: !options.enablePopup,
|
|
|
|
+ popupMode: options.popup,
|
|
|
|
+ onPopup: () => {
|
|
ReactDOM.unmountComponentAtNode(this._ActionTabsHost!);
|
|
ReactDOM.unmountComponentAtNode(this._ActionTabsHost!);
|
|
|
|
|
|
this._RemoveElementFromDOM(this._ActionTabsHost);
|
|
this._RemoveElementFromDOM(this._ActionTabsHost);
|
|
@@ -189,7 +197,8 @@ export class Inspector {
|
|
options.showInspector = true;
|
|
options.showInspector = true;
|
|
options.inspectorWidth = options.popup ? "100%" : "300px";
|
|
options.inspectorWidth = options.popup ? "100%" : "300px";
|
|
Inspector.Show(scene, options);
|
|
Inspector.Show(scene, options);
|
|
- }, onClose: () => {
|
|
|
|
|
|
+ },
|
|
|
|
+ onClose: () => {
|
|
ReactDOM.unmountComponentAtNode(this._ActionTabsHost!);
|
|
ReactDOM.unmountComponentAtNode(this._ActionTabsHost!);
|
|
Inspector._OpenedPane--;
|
|
Inspector._OpenedPane--;
|
|
this._Cleanup();
|
|
this._Cleanup();
|
|
@@ -200,14 +209,13 @@ export class Inspector {
|
|
this._ActionTabsWindow.close();
|
|
this._ActionTabsWindow.close();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- initialTab: options.initialTab
|
|
|
|
|
|
+ initialTab: options.initialTab,
|
|
});
|
|
});
|
|
ReactDOM.render(actionTabsElement, this._ActionTabsHost);
|
|
ReactDOM.render(actionTabsElement, this._ActionTabsHost);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private static _CreateEmbedHost(scene: Scene, options: IInternalInspectorOptions, parentControl: Nullable<HTMLElement>, onSelectionChangedObservable: Observable<string>) {
|
|
private static _CreateEmbedHost(scene: Scene, options: IInternalInspectorOptions, parentControl: Nullable<HTMLElement>, onSelectionChangedObservable: Observable<string>) {
|
|
-
|
|
|
|
// Prepare the inspector host
|
|
// Prepare the inspector host
|
|
if (parentControl) {
|
|
if (parentControl) {
|
|
const host = parentControl.ownerDocument!.createElement("div");
|
|
const host = parentControl.ownerDocument!.createElement("div");
|
|
@@ -227,11 +235,13 @@ export class Inspector {
|
|
if (this._EmbedHost) {
|
|
if (this._EmbedHost) {
|
|
this._OpenedPane++;
|
|
this._OpenedPane++;
|
|
const embedHostElement = React.createElement(EmbedHostComponent, {
|
|
const embedHostElement = React.createElement(EmbedHostComponent, {
|
|
- globalState: this._GlobalState, scene: scene,
|
|
|
|
|
|
+ globalState: this._GlobalState,
|
|
|
|
+ scene: scene,
|
|
extensibilityGroups: options.explorerExtensibility,
|
|
extensibilityGroups: options.explorerExtensibility,
|
|
noExpand: !options.enablePopup,
|
|
noExpand: !options.enablePopup,
|
|
noClose: !options.enableClose,
|
|
noClose: !options.enableClose,
|
|
- popupMode: options.popup, onPopup: () => {
|
|
|
|
|
|
+ popupMode: options.popup,
|
|
|
|
+ onPopup: () => {
|
|
ReactDOM.unmountComponentAtNode(this._EmbedHost!);
|
|
ReactDOM.unmountComponentAtNode(this._EmbedHost!);
|
|
|
|
|
|
if (options.popup) {
|
|
if (options.popup) {
|
|
@@ -246,7 +256,8 @@ export class Inspector {
|
|
options.showInspector = true;
|
|
options.showInspector = true;
|
|
options.embedHostWidth = options.popup ? "100%" : "auto";
|
|
options.embedHostWidth = options.popup ? "100%" : "auto";
|
|
Inspector.Show(scene, options);
|
|
Inspector.Show(scene, options);
|
|
- }, onClose: () => {
|
|
|
|
|
|
+ },
|
|
|
|
+ onClose: () => {
|
|
ReactDOM.unmountComponentAtNode(this._EmbedHost!);
|
|
ReactDOM.unmountComponentAtNode(this._EmbedHost!);
|
|
|
|
|
|
this._OpenedPane = 0;
|
|
this._OpenedPane = 0;
|
|
@@ -258,24 +269,22 @@ export class Inspector {
|
|
this._EmbedHostWindow.close();
|
|
this._EmbedHostWindow.close();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- initialTab: options.initialTab
|
|
|
|
|
|
+ initialTab: options.initialTab,
|
|
});
|
|
});
|
|
ReactDOM.render(embedHostElement, this._EmbedHost);
|
|
ReactDOM.render(embedHostElement, this._EmbedHost);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public static _CreatePopup(title: string, windowVariableName: string, width = 300, height = 800) {
|
|
|
|
|
|
+ public static _CreatePopup(title: string, windowVariableName: string, width = 300, height = 800, lateBinding?: boolean) {
|
|
const windowCreationOptionsList = {
|
|
const windowCreationOptionsList = {
|
|
width: width,
|
|
width: width,
|
|
height: height,
|
|
height: height,
|
|
top: (window.innerHeight - width) / 2 + window.screenY,
|
|
top: (window.innerHeight - width) / 2 + window.screenY,
|
|
- left: (window.innerWidth - height) / 2 + window.screenX
|
|
|
|
|
|
+ left: (window.innerWidth - height) / 2 + window.screenX,
|
|
};
|
|
};
|
|
|
|
|
|
var windowCreationOptions = Object.keys(windowCreationOptionsList)
|
|
var windowCreationOptions = Object.keys(windowCreationOptionsList)
|
|
- .map(
|
|
|
|
- (key) => key + '=' + (windowCreationOptionsList as any)[key]
|
|
|
|
- )
|
|
|
|
- .join(',');
|
|
|
|
|
|
+ .map((key) => key + "=" + (windowCreationOptionsList as any)[key])
|
|
|
|
+ .join(",");
|
|
|
|
|
|
const popupWindow = window.open("", title, windowCreationOptions);
|
|
const popupWindow = window.open("", title, windowCreationOptions);
|
|
if (!popupWindow) {
|
|
if (!popupWindow) {
|
|
@@ -284,6 +293,13 @@ export class Inspector {
|
|
|
|
|
|
const parentDocument = popupWindow.document;
|
|
const parentDocument = popupWindow.document;
|
|
|
|
|
|
|
|
+ // Font
|
|
|
|
+ const newLinkEl = parentDocument.createElement("link");
|
|
|
|
+
|
|
|
|
+ newLinkEl.rel = "stylesheet";
|
|
|
|
+ newLinkEl.href = "https://use.typekit.net/cta4xsb.css";
|
|
|
|
+ parentDocument.head!.appendChild(newLinkEl);
|
|
|
|
+
|
|
parentDocument.title = title;
|
|
parentDocument.title = title;
|
|
parentDocument.body.style.width = "100%";
|
|
parentDocument.body.style.width = "100%";
|
|
parentDocument.body.style.height = "100%";
|
|
parentDocument.body.style.height = "100%";
|
|
@@ -300,6 +316,13 @@ export class Inspector {
|
|
|
|
|
|
this._CopyStyles(window.document, parentDocument);
|
|
this._CopyStyles(window.document, parentDocument);
|
|
|
|
|
|
|
|
+ if (lateBinding) {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // need this for late bindings
|
|
|
|
+ this._CopyStyles(window.document, parentDocument);
|
|
|
|
+ }, 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
(this as any)[windowVariableName] = popupWindow;
|
|
(this as any)[windowVariableName] = popupWindow;
|
|
|
|
|
|
return parentControl;
|
|
return parentControl;
|
|
@@ -331,7 +354,7 @@ export class Inspector {
|
|
enableClose: true,
|
|
enableClose: true,
|
|
handleResize: true,
|
|
handleResize: true,
|
|
enablePopup: true,
|
|
enablePopup: true,
|
|
- ...userOptions
|
|
|
|
|
|
+ ...userOptions,
|
|
};
|
|
};
|
|
|
|
|
|
// Prepare state
|
|
// Prepare state
|
|
@@ -358,8 +381,7 @@ export class Inspector {
|
|
if (options.embedMode && options.showExplorer && options.showInspector) {
|
|
if (options.embedMode && options.showExplorer && options.showInspector) {
|
|
if (options.popup) {
|
|
if (options.popup) {
|
|
this._CreateEmbedHost(scene, options, this._CreatePopup("INSPECTOR", "_EmbedHostWindow"), Inspector.OnSelectionChangeObservable);
|
|
this._CreateEmbedHost(scene, options, this._CreatePopup("INSPECTOR", "_EmbedHostWindow"), Inspector.OnSelectionChangeObservable);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
let parentControl = (options.globalRoot ? options.globalRoot : rootElement!.parentElement) as HTMLElement;
|
|
let parentControl = (options.globalRoot ? options.globalRoot : rootElement!.parentElement) as HTMLElement;
|
|
|
|
|
|
if (!options.overlay && !this._NewCanvasContainer) {
|
|
if (!options.overlay && !this._NewCanvasContainer) {
|
|
@@ -380,8 +402,7 @@ export class Inspector {
|
|
|
|
|
|
this._CreateEmbedHost(scene, options, parentControl, Inspector.OnSelectionChangeObservable);
|
|
this._CreateEmbedHost(scene, options, parentControl, Inspector.OnSelectionChangeObservable);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else if (options.popup) {
|
|
|
|
|
|
+ } else if (options.popup) {
|
|
if (options.showExplorer) {
|
|
if (options.showExplorer) {
|
|
if (this._SceneExplorerHost) {
|
|
if (this._SceneExplorerHost) {
|
|
this._SceneExplorerHost.style.width = "0";
|
|
this._SceneExplorerHost.style.width = "0";
|
|
@@ -470,7 +491,7 @@ export class Inspector {
|
|
if (g.light) {
|
|
if (g.light) {
|
|
this._GlobalState.enableLightGizmo(g.light, false);
|
|
this._GlobalState.enableLightGizmo(g.light, false);
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
if (this._Scene && this._Scene.reservedDataStore && this._Scene.reservedDataStore.gizmoManager) {
|
|
if (this._Scene && this._Scene.reservedDataStore && this._Scene.reservedDataStore.gizmoManager) {
|
|
this._Scene.reservedDataStore.gizmoManager.dispose();
|
|
this._Scene.reservedDataStore.gizmoManager.dispose();
|
|
this._Scene.reservedDataStore.gizmoManager = null;
|
|
this._Scene.reservedDataStore.gizmoManager = null;
|