Merge pull request #6 from SinonJZH/master

优化文件路径合成方式
This commit is contained in:
FGHRSH 2020-03-10 03:09:44 +08:00 committed by GitHub
commit 6dee0e049b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,9 +26,10 @@ if (is_array($modelName)) {
} }
} }
$textures = json_encode($json['textures']); $textures = $json['textures'];
$textures = str_replace('texture', '../model/'.$modelName.'/texture', $textures); foreach ($textures as $key => $texture){
$textures = json_decode($textures, 1); $textures[$key] = '../model/' . $modelName . '/' . $texture;
}
$json['textures'] = $textures; $json['textures'] = $textures;
$json['model'] = '../model/'.$modelName.'/'.$json['model']; $json['model'] = '../model/'.$modelName.'/'.$json['model'];
@ -36,17 +37,27 @@ if (isset($json['pose'])) $json['pose'] = '../model/'.$modelName.'/'.$json['pose
if (isset($json['physics'])) $json['physics'] = '../model/'.$modelName.'/'.$json['physics']; if (isset($json['physics'])) $json['physics'] = '../model/'.$modelName.'/'.$json['physics'];
if (isset($json['motions'])) { if (isset($json['motions'])) {
$motions = json_encode($json['motions']); $motions = $json['motions'];
$motions = str_replace('sounds', '../model/'.$modelName.'/sounds', $motions); foreach ($motions as $key1 => $motion){
$motions = str_replace('motions', '../model/'.$modelName.'/motions', $motions); foreach($motion as $key2 => $resource){
$motions = json_decode($motions, 1); foreach ($resource as $key3 => $value)
if($key3 == 'file'){
$motions[$key1][$key2][$key3] = '../model/' . $modelName . '/' . $value;
}
}
}
$json['motions'] = $motions; $json['motions'] = $motions;
} }
if (isset($json['expressions'])) { if (isset($json['expressions'])) {
$expressions = json_encode($json['expressions']); $expressions = $json['expressions'];
$expressions = str_replace('expressions', '../model/'.$modelName.'/expressions', $expressions); foreach ($expressions as $key1 => $expression){
$expressions = json_decode($expressions, 1); foreach($expression as $key2 => $value){
if($key2 == 'file'){
$expressions[$key1][$key2] = '../model/' . $modelName . '/' . $value;
}
}
}
$json['expressions'] = $expressions; $json['expressions'] = $expressions;
} }