Skip to content

Nightly (#8761) #8762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 48 additions & 49 deletions Playground/src/components/examplesComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from "react";
import { GlobalState } from '../globalState';
import { GlobalState } from "../globalState";

require("../scss/examples.scss");

interface IExamplesComponentProps {
globalState: GlobalState;
}

export class ExamplesComponent extends React.Component<IExamplesComponentProps, {filter: string}> {
export class ExamplesComponent extends React.Component<IExamplesComponentProps, { filter: string }> {
private _state = "removed";
private _rootRef: React.RefObject<HTMLDivElement>;
private _scripts: {
Expand All @@ -19,13 +19,13 @@ export class ExamplesComponent extends React.Component<IExamplesComponentProps,
PGID: string;
description: string;
}[];
}[];
}[];

public constructor(props: IExamplesComponentProps) {
super(props);
this._loadScripts();

this.state = {filter: ""};
this.state = { filter: "" };
this._rootRef = React.createRef();

this.props.globalState.onExamplesDisplayChangedObservable.add(() => {
Expand All @@ -40,18 +40,18 @@ export class ExamplesComponent extends React.Component<IExamplesComponentProps,
this._state = "";
setTimeout(() => {
this._rootRef.current!.classList.add("removed");
}, 200)
}, 200);
}
});
}
}

private _loadScripts() {
var xhr = new XMLHttpRequest();

if (this.props.globalState.language === "JS") {
xhr.open('GET', 'https://raw.githubusercontent.com/BabylonJS/Documentation/master/examples/list.json', true);
xhr.open("GET", "https://raw.githubusercontent.com/BabylonJS/Documentation/master/examples/list.json", true);
} else {
xhr.open('GET', 'https://raw.githubusercontent.com/BabylonJS/Documentation/master/examples/list_ts.json', true);
xhr.open("GET", "https://raw.githubusercontent.com/BabylonJS/Documentation/master/examples/list_ts.json", true);
}

xhr.onreadystatechange = () => {
Expand All @@ -66,7 +66,7 @@ export class ExamplesComponent extends React.Component<IExamplesComponentProps,
return 1;
});

this._scripts.forEach(s => {
this._scripts.forEach((s) => {
s.samples.sort((a, b) => {
if (a.title < b.title) {
return -1;
Expand All @@ -78,12 +78,11 @@ export class ExamplesComponent extends React.Component<IExamplesComponentProps,
this.forceUpdate();
}
}
}
};

xhr.send(null);
}


private _onLoadPG(id: string) {
this.props.globalState.onLoadRequiredObservable.notifyObservers(id);

Expand All @@ -101,46 +100,46 @@ export class ExamplesComponent extends React.Component<IExamplesComponentProps,
<div id="examples" className={this._state} ref={this._rootRef}>
<div id="examples-header">Examples</div>
<div id="examples-filter">
<input id="examples-filter-text" type="text" placeholder="Filter examples" value={this.state.filter} onChange={evt => {
this.setState({filter: evt.target.value});
}}/>
<input
id="examples-filter-text"
type="text"
placeholder="Filter examples"
value={this.state.filter}
onChange={(evt) => {
this.setState({ filter: evt.target.value });
}}
/>
</div>
<div id="examples-list">
{
this._scripts.map(s => {
let active = s.samples.filter(ss => {
return !this.state.filter
|| ss.title.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1
|| ss.description.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1
});

if (active.length === 0) {
return null;
}
{this._scripts.map((s) => {
let active = s.samples.filter((ss) => {
return !this.state.filter || ss.title.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1 || ss.description.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1;
});

if (active.length === 0) {
return null;
}

return(
<div key={s.title} className="example-category">
<div className="example-category-title">
{s.title}
</div>
{
active.map(ss => {
return (
<div className="example" key={ss.title} onClick={() => this._onLoadPG(ss.PGID)}>
<img src={ss.icon.replace("icons", "https://doc.babylonjs.com/examples/icons")}/>
<div className="example-title">{ss.title}</div>
<div className="example-description">{ss.description}</div>
<a className="example-link" href={ss.doc} target="_blank">Documentation</a>
</div>
)
})
}
</div>
)
})
}
return (
<div key={s.title} className="example-category">
<div className="example-category-title">{s.title}</div>
{active.map((ss) => {
return (
<div className="example" key={ss.title} onClick={() => this._onLoadPG(ss.PGID)}>
<img src={ss.icon.replace("icons", "https://doc.babylonjs.com/examples/icons")} />
<div className="example-title">{ss.title}</div>
<div className="example-description">{ss.description}</div>
<a className="example-link" href={ss.doc} target="_blank">
Documentation
</a>
</div>
);
})}
</div>
);
})}
</div>
</div>
)
);
}
}
}
42 changes: 24 additions & 18 deletions Playground/src/tools/loadManager.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { GlobalState } from '../globalState';
import { Utilities } from './utilities';
import { GlobalState } from "../globalState";
import { Utilities } from "./utilities";

export class LoadManager {
private _previousHash = "";

public constructor(public globalState: GlobalState) {
// Check the url to prepopulate data
public constructor(public globalState: GlobalState) {
// Check the url to prepopulate data
this._checkHash();
window.addEventListener("hashchange", () => this._checkHash());

globalState.onLoadRequiredObservable.add(id => {
globalState.onLoadRequiredObservable.add((id) => {
globalState.onDisplayWaitRingObservable.notifyObservers(true);
this._loadPlayground(id);
});
}

private _cleanHash() {
var substr = location.hash[1]==='#' ? 2 : 1
var substr = location.hash[1] === "#" ? 2 : 1;
var splits = decodeURIComponent(location.hash.substr(substr)).split("#");

if (splits.length > 2) {
splits.splice(2, splits.length - 2);
}

location.hash = splits.join("#");
};
}

private _checkHash() {
let pgHash = "";
if (location.search && (!location.pathname || location.pathname === '/') && !location.hash) {
if (location.search && (!location.pathname || location.pathname === "/") && !location.hash) {
var query = Utilities.ParseQuery();
if (query.pg) {
pgHash = "#" + query.pg + "#" + (query.revision || "0")
pgHash = "#" + query.pg + "#" + (query.revision || "0");
}
} else if (location.hash) {
if (this._previousHash !== location.hash) {
Expand All @@ -52,27 +52,27 @@ export class LoadManager {
if (pgHash) {
var match = pgHash.match(/^(#[A-Za-z\d]*)(%23)([\d]+)$/);
if (match) {
pgHash = match[1] + '#' + match[3];
pgHash = match[1] + "#" + match[3];
parent.location.hash = pgHash;
}
this._previousHash = pgHash;
this._loadPlayground(pgHash.substr(1));
}
}
}

private _loadPlayground(id: string) {
private _loadPlayground(id: string) {
this.globalState.loadingCodeInProgress = true;
try {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = () => {
if (xmlHttp.readyState === 4) {
if (xmlHttp.status === 200) {

if (xmlHttp.responseText.indexOf("class Playground") !== -1) {
if (this.globalState.language === "JS") {
Utilities.SwitchLanguage("TS", this.globalState);
}
} else { // If we're loading JS content and it's TS page
} else {
// If we're loading JS content and it's TS page
if (this.globalState.language === "TS") {
Utilities.SwitchLanguage("JS", this.globalState);
}
Expand Down Expand Up @@ -100,20 +100,26 @@ export class LoadManager {
}

this.globalState.onCodeLoaded.notifyObservers(JSON.parse(snippet.jsonPayload).code.toString());

this.globalState.onMetadataUpdatedObservable.notifyObservers();
}
}
};

if (id[0] === "#") {
id = id.substr(1);
}

this.globalState.currentSnippetToken = id.split("#")[0];
if (!id.split("#")[1]) id += "#0";
if (!id.split("#")[1]) {
id += "#0";
}

xmlHttp.open("GET", this.globalState.SnippetServerUrl + "/" + id.replace("#", "/"));
xmlHttp.open("GET", this.globalState.SnippetServerUrl + "/" + id.replace(/#/g, "/"));
xmlHttp.send();
} catch (e) {
this.globalState.loadingCodeInProgress = false;
this.globalState.onCodeLoaded.notifyObservers("");
}
}
}
}
22 changes: 22 additions & 0 deletions dist/ktx2Transcoders/msc_basis_transcoder.js

Large diffs are not rendered by default.

Binary file added dist/ktx2Transcoders/msc_basis_transcoder.wasm
Binary file not shown.
Binary file added dist/ktx2Transcoders/uastc_astc.wasm
Binary file not shown.
Binary file added dist/ktx2Transcoders/uastc_bc7.wasm
Binary file not shown.
Loading