Skip to content

v0.1.0-beta.2

Choose a tag to compare

@github-actions github-actions released this 01 Oct 22:22
· 7 commits to main since this release

Closed beta build of @pixi/3d, from commit bdb9eb4.

Download pixi-3d-0.1.0-beta.2.tgz, then install it next to PixiJS:

npm install pixi.js
npm install ./pixi-3d-0.1.0-beta.2.tgz

Imports work exactly as they will from npm:

import { View3D } from '@pixi/3d';
import { OrbitCamera } from '@pixi/3d/extras';

🚨 Behavior Change

  • chore: bump pixi.js peer dependency to 8.22.0 by @Zyie
    npm install pixi.js@^8.22.0
  • breaking: read material rows from the data texture on WebGPU by @GoodBoyDigital
    • This affects custom shader bits that declare material fields.
    • A material field must be f32, u32, i32, a vec2, vec3 or vec4 of f32, or mat2x2<f32>. Creating a material with any other type throws, and the error names the bit and the field. A material struct larger than its 256-byte row also throws, where it used to spill into the next material's data.
    • In WGSL, uMaterialStorage is a texture now, so uMaterialStorage[i] no longer compiles. Read the material local, which both stages have, or call getMaterial(index) for another material's row.
    // before
    let tint = uMaterialStorage[vMaterialIndex].tint;
    // after
    let tint = material.tint;
    • In GLSL, the compiler emits getMaterial() after gl.header, so code in the header can't call it. Code in the stage slots still can.
  • fix: WebGPU batch samplers take the implicit level of detail by @GoodBoyDigital
    • The shader helpers sampleBatchTexture and _unpackSlot are gone from the WGSL and GLSL headers, so a custom ShaderBit that calls them fails to compile. Call the generated sample<Name>(uv) and sample<Name>Direct(uv) getters instead, or sampleBatchSlotGrad(slot, uv, dx, dy) with the slot read from _textureSlots in WGSL or vTextureSlots in GLSL.
  • feat: BatchedMesh3D cull option by @GoodBoyDigital
    • A BatchedMesh3D no longer takes its culling mode from the view. Each batch has its own cull, and it defaults to 'off', so every instance draws. In beta.1 a batch followed the view's cull, which defaults to 'auto'. Turn culling back on for a large batch spread well beyond the view, such as scattered scenery:
    const forest = new BatchedMesh3D({ size: treePositions.length, cull: 'auto' });
  • feat: OrbitCamera and FPSCamera keep the context menu from opening by @Zyie
    • Once a View has an OrbitCamera or FPSCamera, the browser's context menu stops opening over that View. Pass preventContextMenu: false to get it back. The menu also opens while the controller's enabled is false.
    import { OrbitCamera } from '@pixi/3d/extras';
    
    new OrbitCamera({ view: view3d, preventContextMenu: false });
    
    // or for every controller created after this line
    OrbitCamera.defaultOptions.preventContextMenu = false;

🎁 Added

  • feat: View3D.background accepts a Hemisphere by @Zyie
    • View3D's background takes a Hemisphere and draws its sky and ground gradient behind the scene, on WebGL and WebGPU. The gradient uses the same formula as a hemisphere environment, so one object passed to both gives a sky that matches the scene's light. The view's exposure and tone mapping apply, as they do to a cube map. A colour change shows on the next frame. The option also accepts null.
    import { type Hemisphere, View3D } from '@pixi/3d';
    
    const sky: Hemisphere = { skyColor: 0x88ccff, groundColor: 0x553311 };
    const view3d = new View3D({ autoResize: true, environment: sky, background: sky });
    
    sky.skyColor = 0xff8800; // sunset
  • feat: OrbitCamera and FPSCamera keep the context menu from opening by @Zyie
    • OrbitCamera and FPSCamera take a preventContextMenu option, also a property you can change at runtime. It defaults to true, so a right-button pan or a drag to look around no longer opens the browser menu. Windows opens the menu on release, so there a right-button drag that ends outside the View still opens it.
    • 3D nodes receive contextmenu events like the other pointer events, with hit3D set, and gain an oncontextmenu handler property. preventDefault() keeps the browser menu closed. stopPropagation() lets it open and hides the event from the View's own listeners, such as a camera controller's.
    mesh.on('contextmenu', (e) => {
      e.preventDefault();
      openMenuFor(mesh, e.global);
    });
  • feat: read material rows from the data texture on WebGPU by @GoodBoyDigital

⚡ Performance

🐛 Fixed

  • fix: WebGL reads integer data through integer textures by @GoodBoyDigital
  • fix: use the glTF default material for primitives without one by @Zyie
  • fix: WebGL reads integer data through integer textures by @GoodBoyDigital
  • chore: bump pixi.js peer dependency to 8.22.0 by @Zyie
  • fix: shadow auto-fit reads live caster membership, not a stale sort by @Zyie
  • fix: apply View3D visibility and transform changes by @Zyie
  • fix: keep the WebGL bone texture aligned to whole rows when the bone pit grows by @Zyie
  • fix: drop the GGX guard that flattened smooth highlights by @Zyie
  • fix: copy atlas fast-path vertices as bytes and check the layout first by @GoodBoyDigital
  • fix: copies read the target their camera drew, not whatever is bound by @GoodBoyDigital
  • breaking: read material rows from the data texture on WebGPU by @GoodBoyDigital
  • fix: a read-only-depth pass resolves to pixi's default target instead of reconfiguring the canvas by @Zyie
  • fix: shadow passes let go of pipe stores when their renderer is destroyed by @Zyie
  • fix: IBL prefilter and BRDF LUT release their one-shot bind groups by @Zyie

🧹 Chores

  • chore: fact-check the API docs across src by @Zyie
  • chore: fix the glTF viewer, comparison and walrus-cave examples by @Zyie