Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Updating to current state
Browse files Browse the repository at this point in the history
Code is now maintained at the babylonjs extensions repo. I will keep on
updating it here as well.
  • Loading branch information
RaananW committed Jan 2, 2015
1 parent aaef59c commit b7eddae
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 12 deletions.
21 changes: 18 additions & 3 deletions MaterialEditor/canvas/ObjectSubMeshesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@
totalNumberOfIndices: number;
indicesLeft: number;
close: () => void;
updateObject: (closeObject:boolean) => void;
updateObject: (closeObject: boolean) => void;
addSubMesh: () => void;
removeSubMesh: (index:number) => void;
removeSubMesh: (index: number) => void;
division: number;
divideObject: () => void;
}

export class ObjectSubMeshesController {

public static $inject = [
'$scope',
'$timeout',
'$modalInstance',
'object'
];

constructor(private $scope: ObjectSubMeshesScope, private $modalInstance: any, private object: BABYLON.Mesh) {
constructor(private $scope: ObjectSubMeshesScope, private $timeout:ng.ITimeoutService, private $modalInstance: any, private object: BABYLON.Mesh) {

$scope.object = object;
$scope.totalNumberOfIndices = object.getTotalIndices();

$scope.division = 2;

$scope.close = () => {
$scope.updateObject(true);
$modalInstance.close();
Expand Down Expand Up @@ -71,7 +76,17 @@
object.subMeshes.splice(index, 1);
$scope.updateObject(false);
}

$scope.divideObject = () => {
if ($scope.division * 3 > $scope.totalNumberOfIndices) {
$scope.division = ~~($scope.totalNumberOfIndices / 3);
}
object.subdivide($scope.division);
$scope.updateObject(false);
}

$scope.updateObject(false);

}

}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Babylon JS Material Editor v 0.9
Babylon JS Material Editor v 1.0 beta
================================

An AngularJS based typescript project for real-time in browser material editing using BabylonJS (http://babylonjs.com)
Expand All @@ -7,7 +7,7 @@ This is the first release of the material editor, with a simple UI using twitter
Demo
-------

http://my-cac.com/materialEditor
http://materialeditor.raananweber.com/

About the code
----------
Expand Down
15 changes: 14 additions & 1 deletion application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion application.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions application.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions application.min.js.map

Large diffs are not rendered by default.

40 changes: 35 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>

<html lang="en" data-framework="typescript">
<head>
<meta charset="utf-8" />
Expand All @@ -9,6 +8,9 @@
<link rel="stylesheet" href="vendor/ui-color-picker.css" type="text/css" />
<link rel="stylesheet" href="vendor/slider.css" type="text/css" />
<link rel="stylesheet" href="css/main.css" type="text/css" />
<meta name="description" content="A Material editor for babylonjs meshes.">
<meta name="keywords" content="WebGL, BabylonJS, Material editor, 3D, diffuse, bump, reflection, textures, specular">
<meta name="author" content="Raanan Weber">
<script src="vendor/babylonjs-2.0.0-alpha-debug.js"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
Expand All @@ -17,7 +19,7 @@
<script src="vendor/ui-bootstrap.js"></script>
<script src="vendor/ui-color-picker.js"></script>
<script src="vendor/slider.js"></script>
<script src="application.js"></script>
<script src="application.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
Expand Down Expand Up @@ -84,7 +86,7 @@ <h3 class="modal-title">MaterialExport</h3>
<div class="form-group">
<input type="text" class="form-control" placeholder="Material ID" ng-model="materialController.materialId" style="width:140px;">
</div>
<div class="checkbox">
<div class="form-group">
<button class="btn btn-default" ng-click="materialController.loadMaterial()">Load Material</button>
</div>
</form>
Expand All @@ -95,7 +97,7 @@ <h4>Material Index</h4>
</div>
<div class="col-md-6 alphaDiv">
<div class="btn-group" ng-repeat="i in materialController.getMaterialIndices() track by $index">
<label class="btn btn-primary" ng-model="materialController.multiMaterialPosition" ng-click="materialController.initMaterial(false, $index)" btn-radio="{{$index}}">{{$index}}</label>
<label class="btn btn-primary" ng-model="materialController.multiMaterialPosition" ng-click="materialController.initMaterial(false, null, $index)" btn-radio="{{$index}}">{{$index}}</label>
</div>
</div>
</div>
Expand Down Expand Up @@ -331,6 +333,7 @@ <h3 class="modal-title">Object Sub-Meshes - {{object.name}}</h3>
</div>
<div class="modal-body">
<p><span>Total Indices : {{totalNumberOfIndices}}</span> <span>Indices left : {{indicesLeft}}</span></p>

<table class="table">
<thead>
<tr>
Expand All @@ -346,12 +349,27 @@ <h3 class="modal-title">Object Sub-Meshes - {{object.name}}</h3>
<td>{{$index}}</td>
<td>{{subMesh.materialIndex}}<!--<div class="col-xs-5"><input type="number" class="form-control" placeholder="MatIdx" ng-model="subMesh.materialIndex" ng-change="updateObject()"></div>--></td>
<td>{{subMesh.indexStart}}<!--<div class="col-xs-5"><input type="number" step="3" class="form-control" placeholder="IndexStart" ng-model="subMesh.indexStart" ng-change="updateObject()"></div>--></td>
<td><div class="col-xs-5"><input type="number" step="3" class="form-control" placeholder="IndexCount" ng-model="subMesh.indexCount" ng-change="updateObject()"></div></td>
<td><div class="col-xs-5"><input type="number" step="3" class="form-control" placeholder="IndexCount" ng-model="subMesh.indexCount" ng-blur="updateObject()"></div></td>
<td><button class="btn btn-primary" ng-click="removeSubMesh($index)">Remove</button></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" ng-click="addSubMesh()">Add new SubMesh</button>

<div class="form-inline alphaDiv">
<div class="form-group">
<p>Divide the object to</p>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="" ng-model="division" style="width:140px;">
</div>
<div class="form-group">
<p>equal submeshes.</p>
</div>
<div class="form-group">
<button class="btn btn-primary" ng-click="divideObject()">Go</button></p>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="close()">Done</button>
Expand Down Expand Up @@ -425,5 +443,17 @@ <h4>Specular Color</h4>
<p class="text-muted">Created by Raanan Weber (<a href="https://github.com/raananw/">https://github.com/raananw/</a>), 2014.</p>
</div>
</footer>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-58143781-1', 'auto');
ga('send', 'pageview');

</script>
</body>
</html>

0 comments on commit b7eddae

Please sign in to comment.