-
Notifications
You must be signed in to change notification settings - Fork 250
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
Enable orphaned nodes editing #59
Changes from 5 commits
e3187fa
810414a
861efe2
8083fb6
d4298b1
d25fc0a
d02877a
4d4fc96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"entities": { | ||
"New_Node1": { | ||
"parent": "Pillar1x3RndShape", | ||
"index": 0 | ||
}, | ||
"New_Node2": { | ||
"parent": "Pillar1x3RndShape", | ||
"index": 1 | ||
}, | ||
"New_Node3": { | ||
"parent": "Pillar1x3Rnd1", | ||
"index": 0 | ||
}, | ||
"New_Node4": { | ||
"parent": "New_Node3", | ||
"index": 0 | ||
}, | ||
"New_Node5": { | ||
"parent": "New_Node4", | ||
"index": 0 | ||
}, | ||
"New_Node6": { | ||
"parent": "New_Node4", | ||
"index": 0 | ||
}, | ||
"New_Node7": { | ||
"parent": "New_Node6", | ||
"index": 0 | ||
}, | ||
"New_Node8": { | ||
"parent": "New_Node6", | ||
"index": 0 | ||
} | ||
}, | ||
"inherits": "./ArchitectureKit/Pillar1x3Rnd.gltf" | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"entities": { | ||
"New_Node1": { | ||
"parent": "Wall2x3Win1x0_75HorzShape", | ||
"index": 0 | ||
}, | ||
"New_Node2": { | ||
"parent": "Wall2x3Win1x0_75HorzShape1", | ||
"index": 1 | ||
}, | ||
"New_Node3": { | ||
"parent": "Wall2x3Win1x0_75Horz", | ||
"index": 1 | ||
}, | ||
"New_Node4": { | ||
"parent": "New_Node5", | ||
"index": 0 | ||
}, | ||
"New_Node6": { | ||
"parent": "New_Node4", | ||
"index": 0 | ||
} | ||
}, | ||
"inherits": "./ArchitectureKit/Wall2x3Win1x0_75Horz.gltf" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
export default class ConflictHandler { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, if a module exports a single default class, I think we want the file name to match the class name. |
||
constructor() { | ||
this._conflicts = { | ||
missing: false, | ||
duplicate: false | ||
}; | ||
this.duplicateList = {}; | ||
} | ||
|
||
findDuplicates = (node, layer, index) => { | ||
if (node.userData._path) { | ||
node.userData._path.push(index); | ||
} else { | ||
node.userData._path = [0]; | ||
} | ||
|
||
const name = node.name; | ||
this.duplicateList[name] = name in this.duplicateList ? this.duplicateList[name] + 1 : 1; | ||
if (this.duplicateList[name] > 1) { | ||
this.setDuplicateStatus(true); | ||
} | ||
|
||
if (node.children) { | ||
node.children.forEach((child, i) => { | ||
child.userData._path = node.userData._path.slice(0); | ||
this.findDuplicates(child, layer + 1, i); | ||
}); | ||
} | ||
}; | ||
|
||
setDuplicateStatus = newStatus => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a class member is only used internally, or meant for private use, we start them with an underscore. I think that applies to a few of the methods in this class. Also applies to properties like |
||
this._conflicts.duplicate = newStatus; | ||
}; | ||
|
||
setMissingStatus = newStatus => { | ||
this._conflicts.missing = newStatus; | ||
}; | ||
|
||
getDuplicateByName = name => { | ||
if (!(name in this.duplicateList)) { | ||
return false; | ||
} | ||
return this.duplicateList[name] > 1; | ||
}; | ||
|
||
getMissingStatus = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this method is not used anywhere. |
||
return this._conflicts.missing; | ||
}; | ||
|
||
getConflictInfo = () => { | ||
return this._conflicts; | ||
}; | ||
|
||
updateAllDuplicateStatus = scene => { | ||
scene.traverse(child => { | ||
child.userData._duplicate = this.getDuplicateByName(child.name); | ||
child.userData._isDuplicateRoot = child.userData._duplicate; | ||
}); | ||
}; | ||
|
||
updateNodesMissingStatus = scene => { | ||
this.updateNodesConflictInfoByProperty(scene, "_missing"); | ||
}; | ||
|
||
updateNodesDuplicateStatus = scene => { | ||
this.updateNodesConflictInfoByProperty(scene, "_duplicate"); | ||
}; | ||
|
||
updateNodesConflictInfoByProperty = (scene, propertyName) => { | ||
scene.traverse(child => { | ||
if (child === scene) { | ||
return; | ||
} | ||
if (!child.userData._isMissingRoot && !child.userData._isDuplicateRoot) { | ||
child.userData[propertyName] = child.parent ? child.parent.userData[propertyName] : false; | ||
} | ||
}); | ||
}; | ||
|
||
checkResolvedMissinRoot = scene => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
let newStatus = false; | ||
const resolvedList = []; | ||
scene.traverse(child => { | ||
if (child.userData._isMissingRoot) { | ||
if (child.children.length > 0) { | ||
newStatus = true; | ||
} else { | ||
child.userData._isMissingRoot = false; | ||
child.userData._missing = false; | ||
resolvedList.push(child); | ||
} | ||
} | ||
}); | ||
this.setMissingStatus(newStatus); | ||
return resolvedList; | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice job on refactoring this out into a class! It's much cleaner now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually demonstrate duplicate nodes.