Skip to content

Commit

Permalink
Merge branch 'main' into xr-export-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
marklundin authored Jan 24, 2024
2 parents ae917ae + 74fbd53 commit d7fc197
Show file tree
Hide file tree
Showing 65 changed files with 2,477 additions and 1,982 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ async function example({ canvas, deviceType, assetPath, scriptsPath, glslangPath
// @ts-ignore
pc.ContainerHandler,
// @ts-ignore
pc.ScriptHandler
pc.ScriptHandler,
// @ts-ignore
pc.GSplatHandler
];

const app = new pc.AppBase(canvas);
app.init(createOptions);

pcx.registerPlyParser(app);

// Set the canvas to fill the window and automatically change resolution to be the same as the canvas size
app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
app.setCanvasResolution(pc.RESOLUTION_AUTO);
Expand All @@ -55,8 +55,8 @@ async function example({ canvas, deviceType, assetPath, scriptsPath, glslangPath

const assets = {
gallery: new pc.Asset('gallery', 'container', { url: assetPath + 'models/vr-gallery.glb' }),
guitar: new pc.Asset('splat', 'container', { url: assetPath + 'splats/guitar.ply' }),
biker: new pc.Asset('splat', 'container', { url: assetPath + 'splats/biker.ply' }),
guitar: new pc.Asset('splat', 'gsplat', { url: assetPath + 'splats/guitar.ply' }),
biker: new pc.Asset('splat', 'gsplat', { url: assetPath + 'splats/biker.ply' }),
orbit: new pc.Asset('script', 'script', { url: scriptsPath + 'camera/orbit-camera.js' })
};

Expand Down Expand Up @@ -123,7 +123,7 @@ async function example({ canvas, deviceType, assetPath, scriptsPath, glslangPath
return app;
}

export class SplatManyExample {
export class GSplatManyExample {
static CATEGORY = 'Loaders';
static example = example;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ async function example({ canvas, deviceType, assetPath, scriptsPath, glslangPath
// @ts-ignore
pc.ContainerHandler,
// @ts-ignore
pc.ScriptHandler
pc.ScriptHandler,
// @ts-ignore
pc.GSplatHandler
];

const app = new pc.AppBase(canvas);
app.init(createOptions);

pcx.registerPlyParser(app);

// Set the canvas to fill the window and automatically change resolution to be the same as the canvas size
app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
app.setCanvasResolution(pc.RESOLUTION_AUTO);
Expand All @@ -54,7 +54,7 @@ async function example({ canvas, deviceType, assetPath, scriptsPath, glslangPath
});

const assets = {
biker: new pc.Asset('splat', 'container', { url: assetPath + 'splats/biker.ply' }),
biker: new pc.Asset('splat', 'gsplat', { url: assetPath + 'splats/biker.ply' }),
orbit: new pc.Asset('script', 'script', { url: scriptsPath + 'camera/orbit-camera.js' })
};

Expand Down Expand Up @@ -105,7 +105,7 @@ async function example({ canvas, deviceType, assetPath, scriptsPath, glslangPath
return app;
}

export class SplatExample {
export class GSplatExample {
static CATEGORY = 'Loaders';
static example = example;
}
4 changes: 2 additions & 2 deletions examples/src/examples/loaders/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export * from "./loaders-gl.mjs";
export * from './glb.mjs';
export * from './gltf-export.mjs';
export * from './obj.mjs';
export * from './splat.mjs';
export * from './splat-many.mjs';
export * from './gsplat.mjs';
export * from './gsplat-many.mjs';
export * from './usdz-export.mjs';
7 changes: 7 additions & 0 deletions extras/exporters/core-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const textureBlitFragmentShader = `
gl_FragColor = texture2D(blitTexture, uv0);
}`;

/**
* The base class for the exporters, implementing shared functionality.
*
* @category Exporter
*/
class CoreExporter {
/**
* Create a new instance of the exporter.
Expand All @@ -33,6 +38,8 @@ class CoreExporter {
* @param {import('playcanvas').Color} [options.color] - The tint color to modify the texture with.
* @param {number} [options.maxTextureSize] - Maximum texture size. Texture is resized if over the size.
* @returns {Promise<HTMLCanvasElement>|Promise<undefined>} - The canvas element containing the image.
*
* @ignore
*/
textureToCanvas(texture, options = {}) {

Expand Down
2 changes: 2 additions & 0 deletions extras/exporters/gltf-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const textureSemantics = [

/**
* Implementation of the GLTF 2.0 format exporter.
*
* @category Exporter
*/
class GltfExporter extends CoreExporter {
/**
Expand Down
2 changes: 2 additions & 0 deletions extras/exporters/usdz-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const materialValueTemplate = (type, name, value) => ` ${type

/**
* Implementation of the USDZ format exporter. Note that ASCII version of the format (USDA) is used.
*
* @category Exporter
*/
class UsdzExporter extends CoreExporter {
/**
Expand Down
6 changes: 0 additions & 6 deletions extras/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ export { MiniStats } from './mini-stats/mini-stats.js';
export { UsdzExporter } from './exporters/usdz-exporter.js';
export { GltfExporter } from './exporters/gltf-exporter.js';

// splat
export { registerPlyParser, getDefaultPlyElements } from './splat/ply-parser.js';
export { Splat } from './splat/splat.js';
export { SplatData } from './splat/splat-data.js';
export { SplatInstance } from './splat/splat-instance.js';

// render passes
export { RenderPassCameraFrame } from './render-passes/render-pass-camera-frame.js';
export { RenderPassCompose } from './render-passes/render-pass-compose.js';
Expand Down
78 changes: 0 additions & 78 deletions extras/splat/ply-parser.js

This file was deleted.

54 changes: 34 additions & 20 deletions src/core/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@ import { EventHandler } from './event-handler.js';
* @augments EventHandler
*/
class Tags extends EventHandler {
/**
* Fired for each individual tag that is added.
*
* @event
* @example
* tags.on('add', (tag, parent) => {
* console.log(`${tag} added to ${parent.name}`);
* });
*/
static EVENT_ADD = 'add';

/**
* Fired for each individual tag that is removed.
*
* @event
* @example
* tags.on('remove', (tag, parent) => {
* console.log(`${tag} removed from ${parent.name}`);
* });
*/
static EVENT_REMOVE = 'remove';

/**
* Fired when tags have been added or removed. It will fire once on bulk changes, while `add`
* and `remove` will fire on each tag operation.
*
* @event
* @example
* tags.on('change', (parent) => {
* console.log(`Tags changed on ${parent.name}`);
* });
*/
static EVENT_CHANGE = 'change';

/** @private */
_index = {};

Expand All @@ -24,26 +58,6 @@ class Tags extends EventHandler {
this._parent = parent;
}

/**
* @event Tags#add
* @param {string} tag - Name of a tag added to a set.
* @param {object} parent - Parent object who tags belong to.
*/

/**
* @event Tags#remove
* @param {string} tag - Name of a tag removed from a set.
* @param {object} parent - Parent object who tags belong to.
*/

/**
* Fires when tags have been added or removed. It will fire once on bulk changes, while
* `add`/`remove` will fire on each tag operation.
*
* @event Tags#change
* @param {object} [parent] - Parent object who tags belong to.
*/

/**
* Add a tag, duplicates are ignored. Can be array or comma separated arguments for multiple tags.
*
Expand Down
4 changes: 3 additions & 1 deletion src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { CssHandler } from './handlers/css.js';
import { CubemapHandler } from './handlers/cubemap.js';
import { FolderHandler } from './handlers/folder.js';
import { FontHandler } from './handlers/font.js';
import { GSplatHandler } from './handlers/gsplat.js';
import { HierarchyHandler } from './handlers/hierarchy.js';
import { HtmlHandler } from './handlers/html.js';
import { JsonHandler } from './handlers/json.js';
Expand Down Expand Up @@ -209,7 +210,8 @@ class Application extends AppBase {
TextureAtlasHandler,
SpriteHandler,
TemplateHandler,
ContainerHandler
ContainerHandler,
GSplatHandler
];
}
}
Expand Down
Loading

0 comments on commit d7fc197

Please sign in to comment.