Skip to content

Commit

Permalink
support VRM outline again
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Shimada committed May 23, 2024
1 parent 6944e2f commit 3fa4b2f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/foundation/importer/ModelConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,22 @@ export class ModelConverter {

const rnPrimitive = new Primitive();

const material =
const rnMaterial =
primitive.material != null
? rnMaterials[primitive.material]
: this.__setupMaterial(gltfModel);
setupMaterialVariants(rnPrimitive, primitive);

if (rnMaterial.materialTypeName.indexOf('MToon') !== -1) {
const VRMProperties = gltfModel.extensions.VRM;
const rnExtension = VRMProperties.rnExtension;
const renderPassOutline = rnExtension.renderPassOutline;
const outlineMaterial = primitive.materialObject?.extras?.outlineMaterial;
if (outlineMaterial != null) {
renderPassOutline.setMaterialForPrimitive(outlineMaterial, rnPrimitive);
}
}

// indices
let indicesRnAccessor;
const map: Map<VertexAttributeSemanticsJoinedString, Accessor> = new Map();
Expand Down Expand Up @@ -654,7 +664,7 @@ export class ModelConverter {
}
}

rnPrimitive.setData(map, rnPrimitiveMode, material, indicesRnAccessor);
rnPrimitive.setData(map, rnPrimitiveMode, rnMaterial, indicesRnAccessor);

// morph targets
if (primitive.targets != null) {
Expand Down Expand Up @@ -833,7 +843,6 @@ export class ModelConverter {

private static __setVRM1Material(
gltfModel: RnM2,
// primitive: RnM2Primitive,
materialJson: RnM2Material,
rnLoaderOptions: GltfLoadOption
): Material | undefined {
Expand Down Expand Up @@ -887,7 +896,7 @@ export class ModelConverter {
outlineMaterial = MaterialHelper.createEmptyMaterial();
}

// renderPassOutline.setMaterialForPrimitive(outlineMaterial, rnPrimitive);
materialJson.extras!.outlineMaterial = outlineMaterial;
}

const material = MaterialHelper.createMToonMaterial({
Expand Down Expand Up @@ -970,7 +979,7 @@ export class ModelConverter {
outlineMaterial = MaterialHelper.createEmptyMaterial();
}

// renderPassOutline.setMaterialForPrimitive(outlineMaterial, rnPrimitive);
materialJson.extras!.outlineMaterial = outlineMaterial;
}

const material = MaterialHelper.createMToonMaterial({
Expand Down

0 comments on commit 3fa4b2f

Please sign in to comment.