-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseNameAndFile.ps1
More file actions
28 lines (23 loc) · 1.13 KB
/
parseNameAndFile.ps1
File metadata and controls
28 lines (23 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Include functions to execute javascript
. ((Split-Path $MyInvocation.MyCommand.Path) + "\execJavaScript.ps1")
Function AddNamesToModels([string] $Folder, [string] $NamedModelFolder) {
# The scene's index.html file creates a javascript object that holds information about the name of each file
# We need to open the index.html file and get the information we need from that javascript object
# This function opens the html file and runs a snippet of javascript that extracts the information we need
$json = OpenUrlAndRunScript -Url "$Folder/index.html" -Script @'
var nameAndFile = [];
sceneObjectDescriptors.forEach(function (obj) {
nameAndFile.push({ name: obj.name, file: obj.filename })
});
return JSON.stringify(nameAndFile);
'@
# Parse the json
$nameAndFile = "$json" | ConvertFrom-Json
# Create a new folder for our model files
New-Item $NamedModelFolder -ItemType directory -Force
$nameAndFile | ForEach {
$sourcePath = "$Folder/" + $_.file
$targetPath = "$NamedModelFolder/" + $_.name + ".obj"
Copy-Item $sourcePath $targetPath
}
}