Skip to content

Commit

Permalink
Upgrade to playcanvas 1.73.4 (#30)
Browse files Browse the repository at this point in the history
* Branch 1.71

* GS reorder fix (playcanvas#6409)

* Gsplat rendering fix (playcanvas#6590)

* [Fix] Add missing exposure handling from the Neutral tonemapping (playcanvas#6592)

* Examples app bundle v1 (playcanvas#6594)

* treeshake smallest enabled

* ignore playcanvas PCUI from being treeshaken

* treeshake ignore only pcui

* added device type constants directly (no playcanvas dependency)

* format rollup

* Updated PCUI

* removed PCUI aliasing

* added publint to ci; removed build:publish (playcanvas#6595)

* replaces slashes for windows (playcanvas#6603)

* fixed using query params with iframe example (playcanvas#6605)

* Fix types for calcAabb functions (playcanvas#6596)

* Exports and types fixes v1 (playcanvas#6624)

* cleaned up ts and js config; adds debug and profiler to exports

* set module resolution to node

* Examples config fixes v1 (playcanvas#6627)

* added package json for linting of example modules and renamed @examples to examples

* fixed missing merge conflict

* fixed fallback options (playcanvas#6629)

* fixed example types (playcanvas#6635)

* adjusted publint error

* Fix URL handling in ScriptHandler (playcanvas#6639) (playcanvas#6655)

* Particle system uses uint16 indices instead of uint32 (playcanvas#6661)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>

* Fix the definition of sheenTint Standard Material property (playcanvas#6665)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>

* Update to skybox shader to map it closer to the infinity (playcanvas#6664)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>

* Fix shader chunk error for tonemapped compressed GS (playcanvas#6670)

* Cherry picked: Add JSDoc for getters (playcanvas#6685)

* Gsplat fixes (playcanvas#6710)

* GSplat reorder and shader speedup (playcanvas#6715) (playcanvas#6716)

* Update setFromMat4 and add tests (playcanvas#6720)

* Do not compile different shader for opacity of 1 and diffuse tint of white (playcanvas#6721)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>

* Compressed splat update (playcanvas#6746)

* Unify gsplat shaders (playcanvas#6753)

* Branch 1.72

* Fix gsplat example (playcanvas#6754)

* Improve some JSDoc class descriptions (playcanvas#6725)

* Improve some JSDoc class descriptions

* Lint fixes

* Improve GSplatComponent

* Remove redundant debugRender from GSplat examples

* Improve the Color class description

* Leverage WebXR types in public API (playcanvas#6713)

* Improve typings and docs for XrPlane (playcanvas#6708)

* Improve typing for XrPlane#points

* Tweak docs for XrPlane#label

* Improve class description

* Improve orientation docs

* Tweak example source

* Correct XrTrackedImage construction docs

* Tighten type for XrPlane#orientation

* Tweaks to XrAnchor source (playcanvas#6706)

* Tweaks to XrAnchor source

* More minor docs tweaks

* Improve forget docs

* Invoke stopPropagation on pointer events handled by gizmo (playcanvas#6770)

* [Fix] Stencil clearing was not setting up the mask correctly (playcanvas#6778)

* Fix WebXR depth sensing on quest 3 (playcanvas#6774)

* Update Tags class to use spread instead of arguments (playcanvas#6775)

* Use object destructuring with vectors (playcanvas#6777)

* Minor refactor of Curve class (playcanvas#6780)

* Minor refactor of Curve class

* Tweaks to docs

* Gizmo event fix (playcanvas#6790)

* Small gizmo event handler fix (playcanvas#6811)

* Support for OffscreenCanvas in Web Workers (playcanvas#5167)

* Support for OffscreenCanvas in Web Workers playcanvas#2481

* Update graphics-device.js

* Update platform.js

---------

Co-authored-by: Will Eastcott <willeastcott@gmail.com>

* Add gsplat mapping (playcanvas#6824)

* array length fix

* Branch 1.73

* v1.73.0

* [Fix] Fix albedo debug output (playcanvas#6836)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>

* Fix gsplat sorting bug (playcanvas#6845)

* v1.73.1

* Small fix to gsplat sorter (playcanvas#6846)

* Allow blit to backbuffer (playcanvas#6849)

* always assign animation assets to anim component (playcanvas#6863)

* getAnimationAsset returns Asset (playcanvas#6864)

* fixed getAnimationAsset return to be asset

* reverts change as breaking and updates type to match

* Update src/framework/components/anim/component-layer.js

Co-authored-by: Will Eastcott <will@playcanvas.com>

* Update src/framework/components/anim/component-layer.js

Co-authored-by: Will Eastcott <will@playcanvas.com>

---------

Co-authored-by: Will Eastcott <will@playcanvas.com>

* 1.73.2

* v1.73.3

* v1.73.4

* Support for EXT_mesh_gpu_instancing extension (playcanvas#6869)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>

---------

Co-authored-by: Donovan Hutchence <slimbuck7@gmail.com>
Co-authored-by: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com>
Co-authored-by: KPal <48248865+kpal81xd@users.noreply.github.com>
Co-authored-by: Will Eastcott <will@playcanvas.com>
Co-authored-by: kpal <kpal81xd@gmail.com>
Co-authored-by: Mark Lundin <marklundin@users.noreply.github.com>
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
Co-authored-by: mrmaxm <core@moka.co>
Co-authored-by: Michael Franzl <michael@franzl.name>
Co-authored-by: Will Eastcott <willeastcott@gmail.com>
  • Loading branch information
11 people authored Aug 6, 2024
1 parent 4ff1bf5 commit 1ba0644
Show file tree
Hide file tree
Showing 262 changed files with 5,877 additions and 2,474 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Build PlayCanvas
run: npm run build

- name: Run Publint
run: npm run publint

docs:
name: Docs
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
run: npm install

- name: Build PlayCanvas
run: npm run build:publish
run: npm run build

- name: Run Publint
run: npm run publint

- name: Publish to npm
run: npm publish
Expand Down
17 changes: 8 additions & 9 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import * as pc from 'playcanvas';
You can load external scripts into an example using the `loadES5` function as follows:

```js
import { loadES5 } from '@examples/utils';
import { loadES5 } from 'examples/utils';

const CORE = await loadES5('https://cdn.jsdelivr.net/npm/@loaders.gl/core@2.3.6/dist/dist.min.js');
const DRACO = await loadES5('https://cdn.jsdelivr.net/npm/@loaders.gl/draco@2.3.6/dist/dist.min.js');
Expand Down Expand Up @@ -111,22 +111,22 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {

The controls function takes a [pcui observer](https://playcanvas.github.io/pcui/data-binding/using-observers/) as its parameter and returns a set of PCUI components. Check this [link](https://playcanvas.github.io/pcui/examples/todo/) for an example of how to create and use PCUI.

The data observer used in the `controls` function will be made available as an import `@examples/observer` to use in the example file:
The data observer used in the `controls` function will be made available as an import `examples/observer` to use in the example file:

```js
import { data } from '@examples/observer';
import { data } from 'examples/observer';

console.log(data.get('flash'));
```

### Additional files

Any other file you wish to include in your example can be added to the same folder with the example name prepended (e.g. `<exampleName>.shader.vert` and `<exampleName>.shader.frag`). These files can be accessed from the `@examples/files` module (refer to the Example Modules below).
Any other file you wish to include in your example can be added to the same folder with the example name prepended (e.g. `<exampleName>.shader.vert` and `<exampleName>.shader.frag`). These files can be accessed from the `examples/files` module (refer to the Example Modules below).

If you wish to include a file which is a module (e.g. `module.mjs`), use the `localImport` function to include it in your project:

```js
import { localImport } from '@examples/utils';
import { localImport } from 'examples/utils';

// use just the file name without the example name
const data = localImport('data.mjs');
Expand All @@ -145,10 +145,9 @@ By default, the examples app uses the local version of the playcanvas engine loc

The example script allows you to import examples only modules that interact with the environment such as the device selector and controls. These are listed below:

- `@examples/config` - The example config defined in `./src/examples/<category>/<exampleName>/config.mjs`.
- `@examples/utils` - Contains utilities functions such as `localImport` and `loadES5`. The full list of functions can be found in `./iframe/utils.mjs`.
- `@examples/observer` - The observer object `data`.
- `@examples/files` - The real-time file contents of all files used in the example.
- `examples/files` - The real-time file contents of all files used in the example.
- `examples/observer` - The observer object `data`.
- `examples/utils` - Contains utilities functions such as `localImport` and `loadES5`. The full list of functions can be found in `./iframe/utils.mjs`.

## Deployment

Expand Down
6 changes: 3 additions & 3 deletions examples/iframe/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"imports": {
"playcanvas": '@ENGINE',
"fflate": "../../modules/fflate/esm/browser.js",
"@examples/utils": "./utils.mjs",
"@examples/observer": "./observer.mjs",
"@examples/files": "./files.mjs"
"examples/utils": "./utils.mjs",
"examples/observer": "./observer.mjs",
"examples/files": "./files.mjs"
}
}
</script>
Expand Down
27 changes: 5 additions & 22 deletions examples/iframe/loader.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { updateDeviceType, fetchFile, localImport, clearImports, fire } from '@examples/utils';
import { data, refresh } from '@examples/observer';
import files from '@examples/files';
import { updateDeviceType, fetchFile, localImport, clearImports, parseConfig, fire } from 'examples/utils';
import { data, refresh } from 'examples/observer';
import files from 'examples/files';

import MiniStats from './ministats.mjs';

Expand Down Expand Up @@ -68,23 +68,6 @@ class ExampleLoader {
this._allowRestart = true;
}

/**
* @param {string} script - The script to parse.
* @returns {Record<string, any>} - The parsed config.
*/
_parseConfig(script) {
const regex = /\/\/ @config ([^ \n]+) ?([^\n]+)?/g;
let match;
/** @type {Record<string, any>} */
const config = {};
while ((match = regex.exec(script)) !== null) {
const key = match[1];
const val = match[2];
config[key] = /true|false/g.test(val) ? val === 'true' : val ?? true;
}
return config;
}

/**
* @param {string} stack - The stack trace.
* @returns {{ file: string, line: number, column: number }[]} - The error locations.
Expand Down Expand Up @@ -119,7 +102,7 @@ class ExampleLoader {
window.top.pc = window.pc;

// extracts example category and name from the URL
const match = /([^/]+)\.html$/.exec(location.href);
const match = /([^/]+)\.html$/.exec(new URL(location.href).pathname);
if (!match) {
return;
}
Expand Down Expand Up @@ -147,7 +130,7 @@ class ExampleLoader {
refresh();

// parse config
this._config = this._parseConfig(files['example.mjs']);
this._config = parseConfig(files['example.mjs']);

// update device type
updateDeviceType(this._config);
Expand Down
2 changes: 1 addition & 1 deletion examples/iframe/ministats.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getQueryParams } from '@examples/utils';
import { getQueryParams } from 'examples/utils';

const params = getQueryParams(window.top?.location.href ?? '');

Expand Down
3 changes: 3 additions & 0 deletions examples/iframe/observer.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Observer } from './playcanvas-observer.mjs';

/**
* @type {Observer}
*/
let data;
function refresh() {
data = new Observer({});
Expand Down
8 changes: 8 additions & 0 deletions examples/iframe/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "examples",
"exports": {
"./files": "./files.mjs",
"./observer": "./observer.mjs",
"./utils": "./utils.mjs"
}
}
29 changes: 25 additions & 4 deletions examples/iframe/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import files from '@examples/files';
import files from 'examples/files';

const href = window.top?.location.href ?? '';
const params = getQueryParams(href);
Expand Down Expand Up @@ -56,7 +56,7 @@ const blobUrls = [];
* Imports a local file as a module.
*
* @param {string} name - The name of the local file.
* @returns {Promise<Object>} - The module exports.
* @returns {Promise<any>} - The module exports.
*/
export function localImport(name) {
if (!/\.mjs$/.test(name)) {
Expand All @@ -75,18 +75,36 @@ export function clearImports() {
blobUrls.forEach(URL.revokeObjectURL);
}

/**
* @param {string} script - The script to parse.
* @returns {Record<string, any>} - The parsed config.
*/
export function parseConfig(script) {
const regex = /\/\/ @config ([^ \n]+) ?([^\n]+)?/g;
let match;
/** @type {Record<string, any>} */
const config = {};
while ((match = regex.exec(script)) !== null) {
const key = match[1].trim();
const val = match[2]?.trim();
config[key] = /true|false/g.test(val) ? val === 'true' : val ?? true;
}
return config;
}

const DEVICE_TYPES = ['webgpu', 'webgl2', 'webgl1'];

/**
* @param {{ WEBGPU_DISABLED: boolean; WEBGL_DISABLED: boolean; WEBGL1_DISABLED: boolean; }} config - The configuration object.
* @param {any} config - The configuration object.
* @returns {string} - The device type.
*/
function getDeviceType(config) {
if (params.deviceType && DEVICE_TYPES.includes(params.deviceType)) {
console.warn("Overwriting default deviceType from URL: ", params.deviceType);
return params.deviceType;
}

const selectedDevice = localStorage.getItem('preferredGraphicsDevice');
const selectedDevice = localStorage.getItem('preferredGraphicsDevice') ?? 'webgl2';

switch (selectedDevice) {
case 'webgpu':
Expand Down Expand Up @@ -119,6 +137,9 @@ function getDeviceType(config) {

export let deviceType = 'webgl2';

/**
* @param {Record<string, any>} config - The configuration object.
*/
export function updateDeviceType(config) {
deviceType = getDeviceType(config);
}
Expand Down
19 changes: 7 additions & 12 deletions examples/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
{
"compilerOptions": {
"checkJs": true,
"outDir": "dist",
"noImplicitAny": true,
"strictNullChecks": true,
"module": "esnext",
"target": "es2020",
"allowJs": true,
"jsx": "react",
"lib": [
"es2019",
"dom"
],
"allowSyntheticDefaultImports" : true,
"checkJs": true,
"esModuleInterop" : true,
"moduleResolution" : "node"
"module": "Node16",
"moduleResolution": "Node16",
"noImplicitAny": true,
"outDir": "dist",
"strictNullChecks": true,
"target": "ESNext",
},
"include": ["src", "scripts", "iframe", "utils"],
"exclude": ["node_modules", "src/lib"]
Expand Down
Loading

0 comments on commit 1ba0644

Please sign in to comment.