Skip to content
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

Scene Getter & Asserts #523

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions support/proxy/vwf.example.com/assert.js

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

28 changes: 28 additions & 0 deletions support/proxy/vwf.example.com/assert.vwf.yaml
@@ -0,0 +1,28 @@
# Copyright 2014 Lockheed Martin Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

methods:

# A C++ style assert
# NOTE: these only fire if you have the console open.
# Arguments:
# value - the value we're checking. If true, we log and halt.
# message - the message to log if the assert fails. Optional.
# dontHalt - if true, we just log the message. Optional.
assert:

scripts:
- source: "http://vwf.example.com/assert.js"
72 changes: 72 additions & 0 deletions support/proxy/vwf.example.com/sceneGetter.js

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

42 changes: 41 additions & 1 deletion support/proxy/vwf.example.com/sceneGetter.vwf.yaml
Expand Up @@ -18,7 +18,18 @@ properties:
scene:
get: |
if ( !this.scene ) {
this.scene = this.find( this.scenePath || "/" )[ 0 ];
var sp = this.scenePath || "/";
this.scene = this.find( sp )[ 0 ];
// If this is the prototype object then it will think that it is the
// scene (because it is directly attached to the root) - in that case,
// we want to make sure that we don't incorrectly set this.scene, so
// just short-circuit and return undefined.
if ( this.scene === this ) {
this.scene = undefined;
} else if ( !this.scene ) {
this.logger.errorx( "scene.get",
"Could not find scene node: '" + sp + "'" );
}
}
return this.scene;
//@ sourceURL=sceneGetter.scene.get
Expand All @@ -31,3 +42,32 @@ properties:
// Nullify the current scene so that next time it is gotten, it will find it from the new path
this.scene = null;
//@ sourceURL=sceneGetter.scenePath.set

methods:

# A helper that does basically what Find does, except that it handles some of
# the busywork (and assumes that we'll be looking in the scene).
# NOTE: THIS ONLY GETS THE FIRST OBJECT FOUND. If you want the whole array,
# you'll need to extend this function (or write another).
# Arguments:
# objectName - the name of the object to search for
# errorOnNotFound - if true (the default) we log an error if the object is
# not found.
# warnOnTooMany - if true (the default) we log a warning if more than one
# object is found.
findInScene:

# Same as findInScene, except that this looks by type rather than by name.
# NOTE: THIS ONLY GETS THE FIRST OBJECT FOUND. If you want the whole array,
# you'll need to extend this function (or write another).
# Arguments:
# typeName - the type to search for (where the "type" is the filename
# that the object extends).
# errorOnNotFound - if true (the default) we log an error if the object is
# not found.
# warnOnTooMany - if true (the default) we log a warning if more than one
# object is found.
findTypeInScene:

scripts:
- source: "http://vwf.example.com/sceneGetter.js"