Skip to content

Commit

Permalink
fix: simplify VRM extension checks in ModelConverter by using optiona…
Browse files Browse the repository at this point in the history
…l chaining and improve readability
  • Loading branch information
Yuki Shimada committed Jan 12, 2025
1 parent 677efca commit 057e9cc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/foundation/importer/ModelConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ export class ModelConverter {

if (rnMaterial.materialTypeName.indexOf('MToon') !== -1) {
const VRMProperties = gltfModel.extensions.VRM;
const rnExtension = VRMProperties.rnExtension;
if (rnExtension != null) {
if (VRMProperties?.rnExtension != null) {
const rnExtension = VRMProperties.rnExtension;
const renderPassOutline = rnExtension.renderPassOutline;
const outlineMaterial = primitive.materialObject?.extras?.outlineMaterial?.deref();
if (outlineMaterial != null) {
Expand Down Expand Up @@ -807,8 +807,8 @@ export class ModelConverter {

// outline
let renderPassOutline;
const rnExtension = VRMProperties.rnExtension;
if (Is.exist(rnExtension)) {
if (Is.exist(VRMProperties?.rnExtension)) {
const rnExtension = VRMProperties.rnExtension;
renderPassOutline = rnExtension.renderPassOutline;
renderPassOutline.isVrRendering = true;
renderPassOutline.tryToSetUniqueName('VRM Outline RenderPass', true);
Expand Down Expand Up @@ -983,8 +983,8 @@ export class ModelConverter {

// outline
let renderPassOutline;
const rnExtension = VRMProperties.rnExtension;
if (Is.exist(rnExtension)) {
if (Is.exist(VRMProperties?.rnExtension)) {
const rnExtension = VRMProperties.rnExtension;
renderPassOutline = rnExtension.renderPassOutline;
renderPassOutline.isVrRendering = true;
renderPassOutline.tryToSetUniqueName('VRM Outline RenderPass', true);
Expand Down

0 comments on commit 057e9cc

Please sign in to comment.