diff --git a/BUILDING.md b/BUILDING.md
index 7146b751b00..28e6861caa4 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -56,9 +56,11 @@ To trigger both incremental debug and release builds:
./build.sh debug release
```
+If build fails for some reasons, it may leave the `out/` directory in a broken state. You can
+force a clean build by adding the `-c` flag in that case.
+
To install the libraries and executables in `out/debug/` and `out/release/`, add the `-i` flag.
-You can force a clean build by adding the `-c` flag. The script offers more features described
-by executing `build.sh -h`.
+The script offers more features described by executing `build.sh -h`.
### Filament-specific CMake Options
@@ -172,12 +174,12 @@ See [ios/samples/README.md](./ios/samples/README.md) for more information.
### Windows
-#### Building on Windows with Visual Studio 2019
+#### Building on Windows with Visual Studio 2019 or later
Install the following components:
-- [Visual Studio 2019](https://www.visualstudio.com/downloads)
-- [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
+- [Visual Studio 2019 or later](https://www.visualstudio.com/downloads)
+- [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)
- [Python 3.7](https://www.python.org/ftp/python/3.7.0/python-3.7.0.exe)
- [CMake 3.14 or later](https://github.com/Kitware/CMake/releases/download/v3.14.7/cmake-3.14.7-win64-x64.msi)
diff --git a/README.md b/README.md
index 3da3ee8f712..1c9b9c01057 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ repositories {
}
dependencies {
- implementation 'com.google.android.filament:filament-android:1.45.0'
+ implementation 'com.google.android.filament:filament-android:1.45.1'
}
```
@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
iOS projects can use CocoaPods to install the latest release:
```shell
-pod 'Filament', '~> 1.45.0'
+pod 'Filament', '~> 1.45.1'
```
### Snapshots
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 8bb4209a27d..453d4f4c169 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -7,12 +7,20 @@ A new header is inserted each time a *tag* is created.
Instead, if you are authoring a PR for the main branch, add your release note to
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).
+## v1.45.1
+
+- engine: Added parameter for configuring JobSystem thread count
+- engine: In Java, introduce Engine.Builder
+- gltfio: fix ubershader index for transmission&volume material
+- engine: New tone mapper: `AgXTonemapper`.
+- matinfo: Add support for viewing ESSL 1.0 shaders
+- engine: Add `Renderer::getClearOptions()` [b/243846268]
+
## v1.45.0
- materials: fix alpha masked materials when MSAA is turned on [⚠️ **Recompile materials**]
- materials: better support materials with custom depth [**Recompile Materials**]
- engine: fade shadows at shadowFar distance instead of hard cutoff [⚠️ **New Material Version**]
-- engine: Add support for stencil buffer when post-processing is disabled (Metal backend only).
## v1.44.0
diff --git a/android/filament-android/src/main/cpp/Engine.cpp b/android/filament-android/src/main/cpp/Engine.cpp
index e530e7bb55b..e5bb4e95fa7 100644
--- a/android/filament-android/src/main/cpp/Engine.cpp
+++ b/android/filament-android/src/main/cpp/Engine.cpp
@@ -25,15 +25,8 @@
using namespace filament;
using namespace utils;
-extern "C" JNIEXPORT jlong JNICALL
-Java_com_google_android_filament_Engine_nCreateEngine(JNIEnv*, jclass, jlong backend,
- jlong sharedContext) {
- return (jlong) Engine::create((Engine::Backend) backend, nullptr, (void*) sharedContext);
-}
-
extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_filament_Engine_nDestroyEngine(JNIEnv*, jclass,
- jlong nativeEngine) {
+Java_com_google_android_filament_Engine_nDestroyEngine(JNIEnv*, jclass, jlong nativeEngine) {
Engine* engine = (Engine*) nativeEngine;
Engine::destroy(&engine);
}
@@ -454,4 +447,50 @@ Java_com_google_android_filament_Engine_nGetActiveFeatureLevel(JNIEnv *, jclass,
jlong nativeEngine) {
Engine* engine = (Engine*) nativeEngine;
return (jint)engine->getActiveFeatureLevel();
-}
\ No newline at end of file
+}
+
+extern "C" JNIEXPORT jlong JNICALL Java_com_google_android_filament_Engine_nCreateBuilder(JNIEnv*,
+ jclass) {
+ Engine::Builder* builder = new Engine::Builder{};
+ return (jlong) builder;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nDestroyBuilder(JNIEnv*,
+ jclass, jlong nativeBuilder) {
+ Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
+ delete builder;
+}
+
+extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBuilderBackend(
+ JNIEnv*, jclass, jlong nativeBuilder, jlong backend) {
+ Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
+ builder->backend((Engine::Backend) backend);
+}
+
+extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBuilderConfig(JNIEnv*,
+ jclass, jlong nativeBuilder, jlong commandBufferSizeMB, jlong perRenderPassArenaSizeMB,
+ jlong driverHandleArenaSizeMB, jlong minCommandBufferSizeMB, jlong perFrameCommandsSizeMB,
+ jlong jobSystemThreadCount) {
+ Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
+ Engine::Config config = {
+ .commandBufferSizeMB = (uint32_t) commandBufferSizeMB,
+ .perRenderPassArenaSizeMB = (uint32_t) perRenderPassArenaSizeMB,
+ .driverHandleArenaSizeMB = (uint32_t) driverHandleArenaSizeMB,
+ .minCommandBufferSizeMB = (uint32_t) minCommandBufferSizeMB,
+ .perFrameCommandsSizeMB = (uint32_t) perFrameCommandsSizeMB,
+ .jobSystemThreadCount = (uint32_t) jobSystemThreadCount,
+ };
+ builder->config(&config);
+}
+
+extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBuilderSharedContext(
+ JNIEnv*, jclass, jlong nativeBuilder, jlong sharedContext) {
+ Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
+ builder->sharedContext((void*) sharedContext);
+}
+
+extern "C" JNIEXPORT jlong JNICALL
+Java_com_google_android_filament_Engine_nBuilderBuild(JNIEnv*, jclass, jlong nativeBuilder) {
+ Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
+ return (jlong) builder->build();
+}
diff --git a/android/filament-android/src/main/cpp/Scene.cpp b/android/filament-android/src/main/cpp/Scene.cpp
index 25e6be09ba4..b1d3d003489 100644
--- a/android/filament-android/src/main/cpp/Scene.cpp
+++ b/android/filament-android/src/main/cpp/Scene.cpp
@@ -71,6 +71,13 @@ Java_com_google_android_filament_Scene_nRemoveEntities(JNIEnv *env, jclass type,
env->ReleaseIntArrayElements(entities, (jint*) nativeEntities, JNI_ABORT);
}
+extern "C" JNIEXPORT jint JNICALL
+Java_com_google_android_filament_Scene_nGetEntityCount(JNIEnv *env, jclass type,
+ jlong nativeScene) {
+ Scene* scene = (Scene*) nativeScene;
+ return (jint) scene->getEntityCount();
+}
+
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_Scene_nGetRenderableCount(JNIEnv *env, jclass type,
jlong nativeScene) {
diff --git a/android/filament-android/src/main/cpp/ToneMapper.cpp b/android/filament-android/src/main/cpp/ToneMapper.cpp
index ea040538cd7..21c7e7ab24d 100644
--- a/android/filament-android/src/main/cpp/ToneMapper.cpp
+++ b/android/filament-android/src/main/cpp/ToneMapper.cpp
@@ -47,6 +47,11 @@ Java_com_google_android_filament_ToneMapper_nCreateFilmicToneMapper(JNIEnv*, jcl
return (jlong) new FilmicToneMapper();
}
+extern "C" JNIEXPORT jlong JNICALL
+Java_com_google_android_filament_ToneMapper_nCreateAgxToneMapper(JNIEnv*, jclass, jint look) {
+ return (jlong) new AgxToneMapper(AgxToneMapper::AgxLook(look));
+}
+
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_ToneMapper_nCreateGenericToneMapper(JNIEnv*, jclass,
jfloat contrast, jfloat midGrayIn, jfloat midGrayOut, jfloat hdrMax) {
diff --git a/android/filament-android/src/main/java/com/google/android/filament/Engine.java b/android/filament-android/src/main/java/com/google/android/filament/Engine.java
index e6bc4d92430..3423e87d056 100644
--- a/android/filament-android/src/main/java/com/google/android/filament/Engine.java
+++ b/android/filament-android/src/main/java/com/google/android/filament/Engine.java
@@ -154,6 +154,184 @@ public enum FeatureLevel {
FEATURE_LEVEL_2
};
+ /**
+ * Constructs Engine
objects using a builder pattern.
+ */
+ public static class Builder {
+ @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
+ private final BuilderFinalizer mFinalizer;
+ private final long mNativeBuilder;
+
+ public Builder() {
+ mNativeBuilder = nCreateBuilder();
+ mFinalizer = new BuilderFinalizer(mNativeBuilder);
+ }
+
+ /**
+ * Sets the {@link Backend} for the Engine.
+ *
+ * @param backend Driver backend to use
+ * @return A reference to this Builder for chaining calls.
+ */
+ public Builder backend(Backend backend) {
+ nSetBuilderBackend(mNativeBuilder, backend.ordinal());
+ return this;
+ }
+
+ /**
+ * Sets a sharedContext for the Engine.
+ *
+ * @param sharedContext A platform-dependant OpenGL context used as a shared context
+ * when creating filament's internal context. On Android this parameter
+ * must be an instance of {@link android.opengl.EGLContext}.
+ * @return A reference to this Builder for chaining calls.
+ */
+ public Builder sharedContext(Object sharedContext) {
+ if (Platform.get().validateSharedContext(sharedContext)) {
+ nSetBuilderSharedContext(mNativeBuilder,
+ Platform.get().getSharedContextNativeHandle(sharedContext));
+ return this;
+ }
+ throw new IllegalArgumentException("Invalid shared context " + sharedContext);
+ }
+
+ /**
+ * Configure the Engine with custom parameters.
+ *
+ * @param config A {@link Config} object
+ * @return A reference to this Builder for chaining calls.
+ */
+ public Builder config(Config config) {
+ nSetBuilderConfig(mNativeBuilder, config.commandBufferSizeMB,
+ config.perRenderPassArenaSizeMB, config.driverHandleArenaSizeMB,
+ config.minCommandBufferSizeMB, config.perFrameCommandsSizeMB,
+ config.jobSystemThreadCount);
+ return this;
+ }
+
+ /**
+ * Creates an instance of Engine
+ *
+ * @return A newly created Engine
, or null
if the GPU driver couldn't
+ * be initialized, for instance if it doesn't support the right version of OpenGL or
+ * OpenGL ES.
+ *
+ * @exception IllegalStateException can be thrown if there isn't enough memory to
+ * allocate the command buffer.
+ */
+ public Engine build() {
+ long nativeEngine = nBuilderBuild(mNativeBuilder);
+ if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
+ return new Engine(nativeEngine);
+ }
+
+ private static class BuilderFinalizer {
+ private final long mNativeObject;
+
+ BuilderFinalizer(long nativeObject) {
+ mNativeObject = nativeObject;
+ }
+
+ @Override
+ public void finalize() {
+ try {
+ super.finalize();
+ } catch (Throwable t) { // Ignore
+ } finally {
+ nDestroyBuilder(mNativeObject);
+ }
+ }
+ }
+ }
+
+ /**
+ * Parameters for customizing the initialization of {@link Engine}.
+ */
+ public static class Config {
+
+ // #defines in Engine.h
+ private static final long FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB = 3;
+ private static final long FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB = 2;
+ private static final long FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB = 1;
+ private static final long FILAMENT_COMMAND_BUFFER_SIZE_IN_MB =
+ FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB * 3;
+
+ /**
+ * Size in MiB of the low-level command buffer arena.
+ *
+ * Each new command buffer is allocated from here. If this buffer is too small the program
+ * might terminate or rendering errors might occur.
+ *
+ * This is typically set to minCommandBufferSizeMB * 3, so that up to 3 frames can be
+ * batched-up at once.
+ *
+ * This value affects the application's memory usage.
+ */
+ public long commandBufferSizeMB = FILAMENT_COMMAND_BUFFER_SIZE_IN_MB;
+
+ /**
+ * Size in MiB of the per-frame data arena.
+ *
+ * This is the main arena used for allocations when preparing a frame.
+ * e.g.: Froxel data and high-level commands are allocated from this arena.
+ *
+ * If this size is too small, the program will abort on debug builds and have undefined
+ * behavior otherwise.
+ *
+ * This value affects the application's memory usage.
+ */
+ public long perRenderPassArenaSizeMB = FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB;
+
+ /**
+ * Size in MiB of the backend's handle arena.
+ *
+ * Backends will fallback to slower heap-based allocations when running out of space and
+ * log this condition.
+ *
+ * If 0, then the default value for the given platform is used
+ *
+ * This value affects the application's memory usage.
+ */
+ public long driverHandleArenaSizeMB = 0;
+
+ /**
+ * Minimum size in MiB of a low-level command buffer.
+ *
+ * This is how much space is guaranteed to be available for low-level commands when a new
+ * buffer is allocated. If this is too small, the engine might have to stall to wait for
+ * more space to become available, this situation is logged.
+ *
+ * This value does not affect the application's memory usage.
+ */
+ public long minCommandBufferSizeMB = FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB;
+
+ /**
+ * Size in MiB of the per-frame high level command buffer.
+ *
+ * This buffer is related to the number of draw calls achievable within a frame, if it is
+ * too small, the program will abort on debug builds and have undefined behavior otherwise.
+ *
+ * It is allocated from the 'per-render-pass arena' above. Make sure that at least 1 MiB is
+ * left in the per-render-pass arena when deciding the size of this buffer.
+ *
+ * This value does not affect the application's memory usage.
+ */
+ public long perFrameCommandsSizeMB = FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB;
+
+ /**
+ * Number of threads to use in Engine's JobSystem.
+ *
+ * Engine uses a utils::JobSystem to carry out paralleization of Engine workloads. This
+ * value sets the number of threads allocated for JobSystem. Configuring this value can be
+ * helpful in CPU-constrained environments where too many threads can cause contention of
+ * CPU and reduce performance.
+ *
+ * The default value is 0, which implies that the Engine will use a heuristic to determine
+ * the number of threads to use.
+ */
+ public long jobSystemThreadCount = 0;
+ }
+
private Engine(long nativeEngine) {
mNativeObject = nativeEngine;
mTransformManager = new TransformManager(nGetTransformManager(nativeEngine));
@@ -177,9 +355,7 @@ private Engine(long nativeEngine) {
*/
@NonNull
public static Engine create() {
- long nativeEngine = nCreateEngine(0, 0);
- if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
- return new Engine(nativeEngine);
+ return new Builder().build();
}
/**
@@ -199,9 +375,9 @@ public static Engine create() {
*/
@NonNull
public static Engine create(@NonNull Backend backend) {
- long nativeEngine = nCreateEngine(backend.ordinal(), 0);
- if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
- return new Engine(nativeEngine);
+ return new Builder()
+ .backend(backend)
+ .build();
}
/**
@@ -223,13 +399,9 @@ public static Engine create(@NonNull Backend backend) {
*/
@NonNull
public static Engine create(@NonNull Object sharedContext) {
- if (Platform.get().validateSharedContext(sharedContext)) {
- long nativeEngine = nCreateEngine(0,
- Platform.get().getSharedContextNativeHandle(sharedContext));
- if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
- return new Engine(nativeEngine);
- }
- throw new IllegalArgumentException("Invalid shared context " + sharedContext);
+ return new Builder()
+ .sharedContext(sharedContext)
+ .build();
}
/**
@@ -914,7 +1086,6 @@ private static void assertDestroy(boolean success) {
}
}
- private static native long nCreateEngine(long backend, long sharedContext);
private static native void nDestroyEngine(long nativeEngine);
private static native long nGetBackend(long nativeEngine);
private static native long nCreateSwapChain(long nativeEngine, Object nativeWindow, long flags);
@@ -971,4 +1142,13 @@ private static void assertDestroy(boolean success) {
private static native int nGetSupportedFeatureLevel(long nativeEngine);
private static native int nSetActiveFeatureLevel(long nativeEngine, int ordinal);
private static native int nGetActiveFeatureLevel(long nativeEngine);
+
+ private static native long nCreateBuilder();
+ private static native void nDestroyBuilder(long nativeBuilder);
+ private static native void nSetBuilderBackend(long nativeBuilder, long backend);
+ private static native void nSetBuilderConfig(long nativeBuilder, long commandBufferSizeMB,
+ long perRenderPassArenaSizeMB, long driverHandleArenaSizeMB,
+ long minCommandBufferSizeMB, long perFrameCommandsSizeMB, long jobSystemThreadCount);
+ private static native void nSetBuilderSharedContext(long nativeBuilder, long sharedContext);
+ private static native long nBuilderBuild(long nativeBuilder);
}
diff --git a/android/filament-android/src/main/java/com/google/android/filament/Scene.java b/android/filament-android/src/main/java/com/google/android/filament/Scene.java
index 283b7024e73..fd425fbeaac 100644
--- a/android/filament-android/src/main/java/com/google/android/filament/Scene.java
+++ b/android/filament-android/src/main/java/com/google/android/filament/Scene.java
@@ -146,18 +146,29 @@ public void removeEntities(@Entity int[] entities) {
}
/**
- * Returns the number of {@link RenderableManager} components in the Scene
.
+ * Returns the total number of Entities in the Scene
, whether alive or not.
*
- * @return number of {@link RenderableManager} components in the Scene
..
+ * @return the total number of Entities in the Scene
.
+ */
+ public int getEntityCount() {
+ return nGetEntityCount(getNativeObject());
+ }
+
+ /**
+ * Returns the number of active (alive) {@link RenderableManager} components in the
+ * Scene
.
+ *
+ * @return number of {@link RenderableManager} components in the Scene
.
*/
public int getRenderableCount() {
return nGetRenderableCount(getNativeObject());
}
/**
- * Returns the number of {@link LightManager} components in the Scene
.
+ * Returns the number of active (alive) {@link LightManager} components in the
+ * Scene
.
*
- * @return number of {@link LightManager} components in the Scene
..
+ * @return number of {@link LightManager} components in the Scene
.
*/
public int getLightCount() {
return nGetLightCount(getNativeObject());
@@ -189,6 +200,7 @@ void clearNativeObject() {
private static native void nAddEntities(long nativeScene, int[] entities);
private static native void nRemove(long nativeScene, int entity);
private static native void nRemoveEntities(long nativeScene, int[] entities);
+ private static native int nGetEntityCount(long nativeScene);
private static native int nGetRenderableCount(long nativeScene);
private static native int nGetLightCount(long nativeScene);
private static native boolean nHasEntity(long nativeScene, int entity);
diff --git a/android/filament-android/src/main/java/com/google/android/filament/ToneMapper.java b/android/filament-android/src/main/java/com/google/android/filament/ToneMapper.java
index 15800562e3e..58ffc501ec1 100644
--- a/android/filament-android/src/main/java/com/google/android/filament/ToneMapper.java
+++ b/android/filament-android/src/main/java/com/google/android/filament/ToneMapper.java
@@ -100,6 +100,45 @@ public Filmic() {
}
}
+ /**
+ * AgX tone mapping operator.
+ */
+ public static class Agx extends ToneMapper {
+
+ public enum AgxLook {
+ /**
+ * Base contrast with no look applied
+ */
+ NONE,
+
+ /**
+ * A punchy and more chroma laden look for sRGB displays
+ */
+ PUNCHY,
+
+ /**
+ * A golden tinted, slightly washed look for BT.1886 displays
+ */
+ GOLDEN
+ }
+
+ /**
+ * Builds a new AgX tone mapper with no look applied.
+ */
+ public Agx() {
+ this(AgxLook.NONE);
+ }
+
+ /**
+ * Builds a new AgX tone mapper.
+ *
+ * @param look: an optional creative adjustment to contrast and saturation
+ */
+ public Agx(AgxLook look) {
+ super(nCreateAgxToneMapper(look.ordinal()));
+ }
+ }
+
/**
* Generic tone mapping operator that gives control over the tone mapping
* curve. This operator can be used to control the aesthetics of the final
@@ -194,6 +233,7 @@ public void setHdrMax(float hdrMax) {
private static native long nCreateACESToneMapper();
private static native long nCreateACESLegacyToneMapper();
private static native long nCreateFilmicToneMapper();
+ private static native long nCreateAgxToneMapper(int look);
private static native long nCreateGenericToneMapper(
float contrast, float midGrayIn, float midGrayOut, float hdrMax);
diff --git a/android/filament-android/src/main/java/com/google/android/filament/View.java b/android/filament-android/src/main/java/com/google/android/filament/View.java
index 6c7b794f304..91622d26c41 100644
--- a/android/filament-android/src/main/java/com/google/android/filament/View.java
+++ b/android/filament-android/src/main/java/com/google/android/filament/View.java
@@ -1930,6 +1930,7 @@ public enum ShadowType {
* PCF with soft shadows and contact hardening
*/
PCSS,
+ PCFd,
}
/**
diff --git a/android/gradle.properties b/android/gradle.properties
index 61ffc823bb5..0fdca3754ec 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1,5 +1,5 @@
GROUP=com.google.android.filament
-VERSION_NAME=1.45.0
+VERSION_NAME=1.45.1
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
diff --git a/docs/viewer/filament-viewer.js b/docs/viewer/filament-viewer.js
index 01439952f48..652d55d8ae4 100644
--- a/docs/viewer/filament-viewer.js
+++ b/docs/viewer/filament-viewer.js
@@ -15,7 +15,7 @@
*/
// If you are bundling this with rollup, webpack, or esbuild, the following URL should be trimmed.
-import { LitElement, html, css } from "https://unpkg.com/lit?module";
+import { LitElement, html, css } from "https://unpkg.com/lit@2.8.0?module";
// This little utility checks if the Filament module is ready for action.
// If so, it immediately calls the given function. If not, it asks the Filament
@@ -287,12 +287,12 @@ class FilamentViewer extends LitElement {
// Dropping a glb file is simple because there are no external resources.
if (this.srcBlob && this.srcBlob.name.endsWith(".glb")) {
this.srcBlob.arrayBuffer().then(buffer => {
- this.asset = this.loader.createAssetFromBinary(new Uint8Array(buffer));
+ this.asset = this.loader.createAsset(new Uint8Array(buffer));
const aabb = this.asset.getBoundingBox();
this.assetRoot = this.asset.getRoot();
this.unitCubeTransform = Filament.fitIntoUnitCube(aabb, zoffset);
this.asset.loadResources();
- this.animator = this.asset.getAnimator();
+ this.animator = this.asset.getInstance().getAnimator();
this.animationStartTime = Date.now();
this._updateOverlay();
});
@@ -304,8 +304,6 @@ class FilamentViewer extends LitElement {
const config = {
normalizeSkinningWeights: true,
- recomputeBoundingBoxes: false,
- ignoreBindTransform: false,
asyncInterval: 30
};
@@ -320,22 +318,20 @@ class FilamentViewer extends LitElement {
resourceLoader.delete();
stbProvider.delete();
ktx2Provider.delete();
- this.animator = this.asset.getAnimator();
+ this.animator = this.asset.getInstance().getAnimator();
this.animationStartTime = Date.now();
}
}, config.asyncInterval);
};
this.srcBlob.arrayBuffer().then(buffer => {
- this.asset = this.loader.createAssetFromJson(new Uint8Array(buffer));
+ this.asset = this.loader.createAsset(new Uint8Array(buffer));
const aabb = this.asset.getBoundingBox();
this.assetRoot = this.asset.getRoot();
this.unitCubeTransform = Filament.fitIntoUnitCube(aabb, zoffset);
const resourceLoader = new Filament.gltfio$ResourceLoader(this.engine,
- config.normalizeSkinningWeights,
- config.recomputeBoundingBoxes,
- config.ignoreBindTransform);
+ config.normalizeSkinningWeights);
const stbProvider = new Filament.gltfio$StbProvider(this.engine);
const ktx2Provider = new Filament.gltfio$Ktx2Provider(this.engine);
@@ -367,12 +363,7 @@ class FilamentViewer extends LitElement {
return response.arrayBuffer();
}).then(arrayBuffer => {
const modelData = new Uint8Array(arrayBuffer);
- if (this.src.endsWith(".glb")) {
- this.asset = this.loader.createAssetFromBinary(modelData);
- } else {
- this.asset = this.loader.createAssetFromJson(modelData);
- }
-
+ this.asset = this.loader.createAsset(modelData);
const aabb = this.asset.getBoundingBox();
this.assetRoot = this.asset.getRoot();
this.unitCubeTransform = Filament.fitIntoUnitCube(aabb, zoffset);
@@ -380,7 +371,7 @@ class FilamentViewer extends LitElement {
const basePath = '' + new URL(this.src, document.location);
this.asset.loadResources(() => {
- this.animator = this.asset.getAnimator();
+ this.animator = this.asset.getInstance().getAnimator();
this.animationStartTime = Date.now();
this._applyMaterialVariant();
}, null, basePath);
@@ -441,14 +432,15 @@ class FilamentViewer extends LitElement {
if (!this.hasAttribute("materialVariant")) {
return;
}
- const names = this.asset.getMaterialVariantNames();
+ const instance = this.asset.getInstance();
+ const names = instance.getMaterialVariantNames();
const index = this.materialVariant;
if (index < 0 || index >= names.length) {
console.error(`Material variant ${index} does not exist in this asset.`);
return;
}
console.info(this.src, `Applying material variant: ${names[index]}`);
- this.asset.applyMaterialVariant(index);
+ instance.applyMaterialVariant(index);
}
}
diff --git a/docs/viewer/index.html b/docs/viewer/index.html
index 8d1ca5a7609..2bbc6b187d3 100644
--- a/docs/viewer/index.html
+++ b/docs/viewer/index.html
@@ -43,7 +43,7 @@