Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.odg#
.DS_Store
/node_modules
/package-lock.json
79 changes: 77 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,80 @@
# See the License for the specific language governing permissions and
# limitations under the License.

release debug clean:
@$(MAKE) --silent -C app/ $@
DEPENDENCIES_PATH = app/dependencies
THEEEJS_VERSION = 105
WEBOTS_VERSION = R2020a

JS_SOURCES = \
$(DEPENDENCIES_PATH)/webots.lib.js \
app/bin/fullscreen.js \
app/bin/observable.js \
app/bin/outline_pass.js \
app/bin/transform_controls.js \
app/bin/undo_stack.js \
app/assets/asset.js \
app/assets/asset_library.js \
app/model/part.js \
app/model/robot.js \
app/commands/commands.js \
app/controller/robot_controller.js \
app/view/dragger.js \
app/view/ghost.js \
app/view/handle.js \
app/view/highlightor.js \
app/view/mediator/part_mediator.js \
app/view/mediator/robot_mediator.js \
app/view/part_browser.js \
app/view/part_viewer.js \
app/view/robot_viewer.js \
app/view/part_selector.js \
app/view/slot_anchors.js \
app/robot_designer.js

# external sources to be downloaded and minified
THREEJS_EXAMPLE_URL = https://cdn.jsdelivr.net/gh/mrdoob/three.js@r$(THEEEJS_VERSION)/examples/js/
THREEJS_EXAMPLE_SOURCES = \
controls/OrbitControls.js
LOCAL_THREEJS_EXAMPLE_SOURCES = $(addprefix $(DEPENDENCIES_PATH)/,$(THREEJS_EXAMPLE_SOURCES))

# Token file used to determine when the last successful installation occurred.
INSTALL_TOKEN = app/install.token

.PHONY: release debug profile update cleanse clean

NPM_EXISTS = $(shell which npm 2> /dev/null)

ifeq ($(NPM_EXISTS),)
release debug profile update:
@echo "# Please install nodejs to build 'webots.min.js' using the instructions on the GitHub wiki."
else
release debug profile update: app/web-robot-designer.js
endif

app/web-robot-designer.js: $(JS_SOURCES) $(LOCAL_THREEJS_EXAMPLE_SOURCES) $(INSTALL_TOKEN)
@echo "# compressing web-robot-designer.js"
@node_modules/.bin/babel $(LOCAL_THREEJS_EXAMPLE_SOURCES) $(JS_SOURCES) -o app/web-robot-designer.js --presets "@babel/preset-env"

$(LOCAL_THREEJS_EXAMPLE_SOURCES):
$(eval FILENAME=$(@:$(DEPENDENCIES_PATH)/%=%))
@echo "# downloading three.js $@"
@mkdir -p $(dir $@)
@wget -qN -O $@ $(THREEJS_EXAMPLE_URL)$(FILENAME)

$(DEPENDENCIES_PATH)/webots.lib.js:
@echo "# downloading $@"
@mkdir -p $(dir $@)
@wget -qN -O $@ https://www.cyberbotics.com/files/repository/www/wwi/$(WEBOTS_VERSION)/webots.lib.js

$(INSTALL_TOKEN): package.json
@echo "# installing npm dependencies"
@npm --silent install 1> /dev/null
@touch $(INSTALL_TOKEN)

cleanse: clean
@echo "# uninstalling npm dependencies"
@npm --silent uninstall 1> /dev/null
@rm -fr node_modules $(INSTALL_TOKEN) package-lock.json

clean:
@rm -fr app/web-robot-designer.js $(DEPENDENCIES_PATH)
2 changes: 0 additions & 2 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/install.token
/dependencies
/node_modules
/package-lock.json
Empty file added app/.npmignore
Empty file.
86 changes: 0 additions & 86 deletions app/Makefile

This file was deleted.

4 changes: 4 additions & 0 deletions app/assets/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ class Asset { // eslint-disable-line no-unused-vars
getSlotNames() {
return Object.keys(this.slots);
}

getRobotName() {
return this.name.split('/')[0];
}
}
20 changes: 18 additions & 2 deletions app/assets/asset_library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
'use strict';

class AssetLibrary extends Observable { // eslint-disable-line no-unused-vars
constructor() {
constructor(pathPrefix = '') {
super();
this.pathPrefix = pathPrefix;
this.assets = [];
fetch('/robot-designer/assets/assets.json')
this.robotNames = [];

fetch(this.pathPrefix + 'robot-designer/assets/assets.json')
.then(response => response.text())
.then((txt) => this._loadAssets(JSON.parse(txt)));
}

getPath() {
return this.pathPrefix + 'robot-designer/assets/';
}

getRobotNames() {
return this.robotNames;
}

getAssetByName(assetName) {
for (let a = 0; a < this.assets.length; a++) {
if (this.assets[a].name === assetName)
Expand All @@ -22,8 +33,13 @@ class AssetLibrary extends Observable { // eslint-disable-line no-unused-vars
Object.keys(assetsData).forEach((assetName) => {
var assetData = assetsData[assetName];
var asset = new Asset(assetName, assetData);
asset.icon = this.pathPrefix + asset.icon;
this.assets.push(asset);
let robotName = asset.getRobotName();
if (!this.robotNames.includes(robotName))
this.robotNames.push(robotName);
});

this.notify('loaded', null);
}
}
15 changes: 0 additions & 15 deletions app/package.json

This file was deleted.

1 change: 0 additions & 1 deletion app/robot-designer.min.js

This file was deleted.

Loading