Skip to content
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

(WIP) glTF export: improve material export #5762

Merged
merged 8 commits into from Nov 10, 2023
Binary file added examples/assets/models/boom-box.glb
Binary file not shown.
6 changes: 6 additions & 0 deletions examples/src/examples/loaders/gltf-export.mjs
Expand Up @@ -32,6 +32,7 @@ async function example({ canvas, deviceType, assetPath, glslangPath, twgslPath,
bench: new pc.Asset('bench', 'container', { url: assetPath + 'models/bench_wooden_01.glb' }),
model: new pc.Asset('model', 'container', { url: assetPath + 'models/bitmoji.glb' }),
board: new pc.Asset('statue', 'container', { url: assetPath + 'models/chess-board.glb' }),
boombox: new pc.Asset('statue', 'container', { url: assetPath + 'models/boom-box.glb' }),
color: new pc.Asset('color', 'texture', { url: assetPath + 'textures/seaside-rocks01-color.jpg' }),
};

Expand Down Expand Up @@ -94,6 +95,11 @@ async function example({ canvas, deviceType, assetPath, glslangPath, twgslPath,
entity3.setLocalScale(0.01, 0.01, 0.01);
app.root.addChild(entity3);

const entity4 = assets.boombox.resource.instantiateRenderEntity();
entity4.setLocalPosition(0, 0.5, -3);
entity4.setLocalScale(100, 100, 100);
app.root.addChild(entity4);

// a render component with a sphere and cone primitives
const material = new pc.StandardMaterial();
material.diffuse = pc.Color.RED;
Expand Down
4 changes: 2 additions & 2 deletions extras/exporters/core-exporter.js
@@ -1,6 +1,6 @@
import {
createShaderFromCode, Texture, BlendState, drawQuadWithShader, RenderTarget,
PIXELFORMAT_RGBA8, FILTER_LINEAR, ADDRESS_CLAMP_TO_EDGE
FILTER_LINEAR, ADDRESS_CLAMP_TO_EDGE
} from 'playcanvas';

const textureBlitVertexShader = `
Expand Down Expand Up @@ -74,7 +74,7 @@ class CoreExporter {
name: 'ExtractedTexture',
width,
height,
format: PIXELFORMAT_RGBA8,
format: texture.format,
cubemap: false,
mipmaps: false,
minFilter: FILTER_LINEAR,
Expand Down