protected override async Task <Response> OnExecute(ExecutionContext context, Request request) { var branch = await context.Branch().ConfigureAwait(false); using var transaction = branch.BeginTransaction(); var serviceNode = new ServiceNode() { Id = NodeId.Create <ServiceNode>(request.Id), ServiceId = request.Id, Metadata = NodeMetadata.Create(context.TimeProvider()) }; if (await branch.Services.PutIfAbsentAsync(serviceNode.Id, serviceNode) .ConfigureAwait(false)) { await transaction.CommitAsync().ConfigureAwait(false); return(new Response() { Service = serviceNode.ToOutput() }); } throw new ExecutionException(ExecutionErrorType.Conflict, $"Service {request.Id} already exist"); }
public async Task Create(string branchId, string?sourceBranchId) { var node = CreateNode(); node.Id = NodeId.Create <TBranchNode>(branchId); node.Metadata = NodeMetadata.Create(timeProvider); node.SourceId = sourceBranchId; if (await branchCache.PutIfAbsentAsync(node.Id, node).ConfigureAwait(false)) { Schema.Create(Ignite, branchId); if (sourceBranchId != null) { if (await Exists(sourceBranchId).ConfigureAwait(false)) { await Schema.Copy(Ignite, sourceBranchId, branchId).ConfigureAwait(false); } else { throw new IgniteException($"Branch {sourceBranchId} does not exist"); } } } }
public static MetadataOutput ToOutput(this NodeMetadata metadata) { return(new MetadataOutput() { CreatedAt = metadata.CreatedAt, UpdatedAt = metadata.UpdatedAt }); }
private object List(NodeMetadata metadata, PropertyInfo property, object item, object parent) { var type = property.PropertyType; var genericType = typeof(TrackableCollection <>).MakeGenericType(type.GenericTypeArguments[0]); var items = ProxyListItems(((IEnumerable <object>)item).ToList()); var args = new[] { parent, metadata[property.Name].Relationship, items, _state }; var proxy = Activator.CreateInstance(genericType, args, null); return(proxy); }
private object Entity(NodeMetadata metadata, PropertyInfo property, object item, object parent) { var propertyMetadata = _metadataFactory.Create(item); if (propertyMetadata.IsIgnored) { return(item); } var type = ProxyUtils.GetTargetType(item); var entity = _session.Uow.Get(ProxyUtils.GetEntityId(item), type) ?? item; return(Create(type, entity)); }
private void AppendRelationshipTracker(IList <IInterceptor> interceptors, NodeMetadata metadata, string propertyName) { if (!metadata.Contains(propertyName)) { return; } var property = metadata[propertyName]; if (property.IsList) { return; } if (!property.HasRelationship) { return; } interceptors.Add(new RelationshipTrackerInterceptor(propertyName)); }
public async Task LoadWithoutMetadata_DifferentContent() { var sampleFileInfo = GetSampleFileInfo(SampleFileName); using (var fileReadStream = sampleFileInfo.OpenRead()) { // loading document first time var firstDocument = new Fb2Document(); await firstDocument.LoadAsync(fileReadStream); RewindStream(fileReadStream); // loading document without unsafe nodes var secondDocument = new Fb2Document(); await secondDocument.LoadAsync(fileReadStream, new Fb2StreamLoadingOptions(loadNamespaceMetadata : false)); firstDocument.Book !.NodeMetadata.Should().NotBeNull(); secondDocument.Book !.NodeMetadata.Should().BeNull(); firstDocument.Bodies.First().NodeMetadata.Should().NotBeNull(); secondDocument.Bodies.First().NodeMetadata.Should().BeNull(); } }
public Body(GetMoviesByTitle query, NodeMetadata nodeMetadata) { _query = query; _nodeMetadata = nodeMetadata; }
static NamedOnnxValue LoadTensorPb(Onnx.TensorProto tensor, IReadOnlyDictionary <string, NodeMetadata> nodeMetaDict) { Type tensorElemType = null; int width = 0; GetTypeAndWidth((Tensors.TensorElementType)tensor.DataType, out tensorElemType, out width); var intDims = new int[tensor.Dims.Count]; for (int i = 0; i < tensor.Dims.Count; i++) { intDims[i] = (int)tensor.Dims[i]; } NodeMetadata nodeMeta = null; string nodeName = string.Empty; if (nodeMetaDict.Count == 1) { nodeMeta = nodeMetaDict.Values.First(); nodeName = nodeMetaDict.Keys.First(); // valid for single node input } else if (nodeMetaDict.Count > 1) { if (tensor.Name.Length > 0) { nodeMeta = nodeMetaDict[tensor.Name]; nodeName = tensor.Name; } else { bool matchfound = false; // try to find from matching type and shape foreach (var key in nodeMetaDict.Keys) { var meta = nodeMetaDict[key]; if (tensorElemType == meta.ElementType && tensor.Dims.Count == meta.Dimensions.Length) { int i = 0; for (; i < meta.Dimensions.Length; i++) { if (meta.Dimensions[i] != -1 && meta.Dimensions[i] != intDims[i]) { break; } } if (i >= meta.Dimensions.Length) { matchfound = true; nodeMeta = meta; nodeName = key; break; } } } if (!matchfound) { // throw error throw new Exception($"No Matching Tensor found in InputOutputMetadata corresponding to the serialized tensor specified"); } } } else { // throw error throw new Exception($"While reading the serliazed tensor specified, metaDataDict has 0 elements"); } if (!nodeMeta.IsTensor) { throw new Exception("LoadTensorFromFile can load Tensor types only"); } if (tensorElemType != nodeMeta.ElementType) { throw new Exception($"{nameof(tensorElemType)} is expected to be equal to {nameof(nodeMeta.ElementType)}"); } if (nodeMeta.Dimensions.Length != tensor.Dims.Count) { throw new Exception($"{nameof(nodeMeta.Dimensions.Length)} is expected to be equal to {nameof(tensor.Dims.Count)}"); } for (int i = 0; i < nodeMeta.Dimensions.Length; i++) { if ((nodeMeta.Dimensions[i] != -1) && (nodeMeta.Dimensions[i] != intDims[i])) { throw new Exception($"{nameof(nodeMeta.Dimensions)}[{i}] is expected to either be -1 or {nameof(intDims)}[{i}]"); } } if (nodeMeta.ElementType == typeof(float)) { return(CreateNamedOnnxValueFromRawData <float>(nodeName, tensor.RawData.ToArray(), sizeof(float), intDims)); } else if (nodeMeta.ElementType == typeof(double)) { return(CreateNamedOnnxValueFromRawData <double>(nodeName, tensor.RawData.ToArray(), sizeof(double), intDims)); } else if (nodeMeta.ElementType == typeof(int)) { return(CreateNamedOnnxValueFromRawData <int>(nodeName, tensor.RawData.ToArray(), sizeof(int), intDims)); } else if (nodeMeta.ElementType == typeof(uint)) { return(CreateNamedOnnxValueFromRawData <uint>(nodeName, tensor.RawData.ToArray(), sizeof(uint), intDims)); } else if (nodeMeta.ElementType == typeof(long)) { return(CreateNamedOnnxValueFromRawData <long>(nodeName, tensor.RawData.ToArray(), sizeof(long), intDims)); } else if (nodeMeta.ElementType == typeof(ulong)) { return(CreateNamedOnnxValueFromRawData <ulong>(nodeName, tensor.RawData.ToArray(), sizeof(ulong), intDims)); } else if (nodeMeta.ElementType == typeof(short)) { return(CreateNamedOnnxValueFromRawData <short>(nodeName, tensor.RawData.ToArray(), sizeof(short), intDims)); } else if (nodeMeta.ElementType == typeof(ushort)) { return(CreateNamedOnnxValueFromRawData <ushort>(nodeName, tensor.RawData.ToArray(), sizeof(ushort), intDims)); } else if (nodeMeta.ElementType == typeof(byte)) { return(CreateNamedOnnxValueFromRawData <byte>(nodeName, tensor.RawData.ToArray(), sizeof(byte), intDims)); } else if (nodeMeta.ElementType == typeof(bool)) { return(CreateNamedOnnxValueFromRawData <bool>(nodeName, tensor.RawData.ToArray(), sizeof(bool), intDims)); } else if (nodeMeta.ElementType == typeof(Float16)) { return(CreateNamedOnnxValueFromRawData <Float16>(nodeName, tensor.RawData.ToArray(), sizeof(ushort), intDims)); } else if (nodeMeta.ElementType == typeof(BFloat16)) { return(CreateNamedOnnxValueFromRawData <BFloat16>(nodeName, tensor.RawData.ToArray(), sizeof(ushort), intDims)); } else { //TODO: Add support for remaining types throw new Exception($"Tensors of type {nameof(nodeMeta.ElementType)} not currently supporte in the LoadTensorFromEmbeddedResource"); } }
public ICypherQuery IncludeRelationships(NodeMetadata metadata) { return(metadata.Properties.Where(x => x.HasRelationship && !x.Relationship.Lazy).Aggregate((ICypherQuery)this, (current, property) => current.OptionalMatch($"(({Conventions.NamedParameterCase(metadata.Name)}){StatementFactory.Relationship(property.Relationship)}({Conventions.NamedParameterCase(property.Name)}:{property.Type.Name}))"))); }
public Count(NodeMetadata node) { _name = Neo4j.Conventions.CamelCase(node.Name); }
public StrLiteral(string value, ParseTreeNode node) { Metadata = new NodeMetadata(node); Value = value; }
static NamedOnnxValue CreateNamedOnnxValueFromTensorProto(Onnx.TensorProto tensorProto, IReadOnlyDictionary <string, NodeMetadata> inputMeta) { Type tensorElemType = null; int elemWidth = 0; GetElementTypeAndWidth((TensorElementType)tensorProto.DataType, out tensorElemType, out elemWidth); var dims = tensorProto.Dims.ToList().ConvertAll(x => (int)x); NodeMetadata nodeMeta = null; if (!inputMeta.TryGetValue(tensorProto.Name, out nodeMeta) || nodeMeta.ElementType != tensorElemType) { throw new Exception("No Matching Tensor found from serialized tensor"); } if (nodeMeta.ElementType == typeof(float)) { return(CreateNamedOnnxValueFromRawData <float>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(float), dims)); } else if (nodeMeta.ElementType == typeof(double)) { return(CreateNamedOnnxValueFromRawData <double>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(double), dims)); } else if (nodeMeta.ElementType == typeof(int)) { return(CreateNamedOnnxValueFromRawData <int>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(int), dims)); } else if (nodeMeta.ElementType == typeof(uint)) { return(CreateNamedOnnxValueFromRawData <uint>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(uint), dims)); } else if (nodeMeta.ElementType == typeof(long)) { return(CreateNamedOnnxValueFromRawData <long>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(long), dims)); } else if (nodeMeta.ElementType == typeof(ulong)) { return(CreateNamedOnnxValueFromRawData <ulong>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(ulong), dims)); } else if (nodeMeta.ElementType == typeof(short)) { return(CreateNamedOnnxValueFromRawData <short>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(short), dims)); } else if (nodeMeta.ElementType == typeof(ushort)) { return(CreateNamedOnnxValueFromRawData <ushort>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(ushort), dims)); } else if (nodeMeta.ElementType == typeof(byte)) { return(CreateNamedOnnxValueFromRawData <byte>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(byte), dims)); } else if (nodeMeta.ElementType == typeof(bool)) { return(CreateNamedOnnxValueFromRawData <bool>(tensorProto.Name, tensorProto.RawData.ToArray(), sizeof(bool), dims)); } else { throw new Exception("Tensors of type " + nameof(nodeMeta.ElementType) + " not currently supported in this tool"); } }
// Return whether node input meta data matches the given dimensions static private bool MatchDimensions(NodeMetadata metadata, IStructuralEquatable expected) { return(expected.Equals(metadata.Dimensions, StructuralComparisons.StructuralEqualityComparer)); }
public static ICypherQuery MatchById(ICypherQuery cypher, NodeMetadata metadata) { return cypher.Match($"({Conventions.NamedParameterCase(metadata.Name)}:{metadata.Name})").Where($"{Conventions.NamedParameterCase(metadata.Name)}.Id in {{id}}"); }
public Node(NodeMetadata metadata, object value) { Metadata = metadata; Value = value; }
public AccentModel() { this.m_charIndices = new Dictionary <char, int>(); for (int i = 0; i < this.m_chars.Length; ++i) { this.m_charIndices[this.m_chars[i]] = i; } this.m_session = new InferenceSession("./Data/russtress/model.onnx"); //sanity check { IReadOnlyDictionary <string, NodeMetadata> inputMetadata = this.m_session.InputMetadata; if (inputMetadata.Count != 1) { throw new ApplicationException("Expected just a single input, but got " + inputMetadata.Count); } NodeMetadata inputNode = inputMetadata.First().Value; if (!inputNode.IsTensor) { throw new ApplicationException("Expected input as tensor"); } this.m_inputShape = inputNode.Dimensions; if (this.m_inputShape.Length != 3 || this.m_inputShape[0] != -1 || this.m_inputShape[1] != MAXLEN || this.m_inputShape[2] != this.m_chars.Length) { throw new ApplicationException($"got weird input shape [{String.Join(",", this.m_inputShape)}], expected [{1},{MAXLEN}, {this.m_chars.Length}]"); } this.m_inputShape[0] = 1; //specify batch size if (inputNode.ElementType != typeof(float)) { throw new ApplicationException($"got input element type '{inputNode.ElementType.Name}', while expected float"); } } //sanity check { IReadOnlyDictionary <string, NodeMetadata> outputMetadata = this.m_session.OutputMetadata; if (outputMetadata.Count != 1) { throw new ApplicationException("Expected just a single output, but got " + outputMetadata.Count); } NodeMetadata outputNode = outputMetadata.First().Value; if (!outputNode.IsTensor) { throw new ApplicationException("Expected output as tensor"); } int[] outputShape = outputNode.Dimensions; if (outputShape.Length != 2 || outputShape[0] != -1 || outputShape[1] != MAXLEN) { throw new ApplicationException($"got weird output shape [{String.Join(",", outputShape)}], expected [{1},{MAXLEN}]"); } if (outputNode.ElementType != typeof(float)) { throw new ApplicationException($"got output element type '{outputNode.ElementType.Name}', while expected float"); } } }
protected bool Equals(NodeMetadata other) { return string.Equals(Id, other.Id); }
public NumericLiteral(dynamic value, ParseTreeNode node) { Metadata = new NodeMetadata(node); Value = value; }
// Return whether node input meta data matches the given dimensions static protected bool DimEquals(NodeMetadata metadata, IStructuralEquatable x) { return(x.Equals(metadata.Dimensions, StructuralComparisons.StructuralEqualityComparer)); }
public async Task CreateSceneAsync() { var canvas = await Canvas.GetElementById( "game-window" ); var engine = await Engine.NewEngine( canvas, true ); // This creates a basic Babylon Scene object (non-mesh) var scene = await Scene.NewScene(engine); await scene.set_clearColor( await Color4.NewColor4( 0.31m, 0.48m, 0.64m, 1 ) ); //add an arcRotateCamera to the scene var camera = await ArcRotateCamera.NewArcRotateCamera( "camera", await Tools.ToRadians(125), await Tools.ToRadians(70), 25, await Vector3.NewVector3(0, 3, 0), scene ); await camera.set_lowerRadiusLimit(10); await camera.set_upperRadiusLimit(40); // This attaches the camera to the canvas await camera.attachControl(true); //array for holding the cannon and "paired" animation group var cannonAnimationPairings = new Dictionary <string, string>(); //array for holding readyToPlay status for the cannons var cannonReadyToPlay = new Dictionary <string, int>(); //Load the tower assets var pirateFortImportEntity = await SceneLoader.ImportMeshAsync( "", "https://models.babylonjs.com/pirateFort/", "pirateFort.glb", scene ); var pirateFortImport = pirateFortImportEntity.ToEntity <SceneLoaderImportMeshEntity>(); var meshes = await pirateFortImport.get_meshes(); await meshes[0].set_name("pirateFort"); var seaMesh = await scene.getMeshByName("sea"); await(await seaMesh.get_material()).set_needDepthPrePass(true); await(await scene.getLightByName("Sun")).set_intensity(12); //Load the cannon model and create clones var cannonImportResult = (await SceneLoader.ImportMeshAsync( "", "https://models.babylonjs.com/pirateFort/", "cannon.glb", scene )).ToEntity <SceneLoaderImportMeshEntity>(); //remove the top level root node var cannonMeshs = await cannonImportResult.get_meshes(); var cannon = (await cannonMeshs[0].getChildren())[0]; await cannon.setParent(null); await cannonMeshs[0].dispose(); //set the metadata of each mesh to filter on later var cannonMeshes = await cannon.getChildMeshes(); for (var i = 0; i < cannonMeshes.Length; i++) { var metadata = await NodeMetadata.NewNodeMetadata(); await metadata.set_name("cannon"); await cannonMeshes[i].set_metadata(metadata); } var importedAnimGroups = await cannonImportResult.get_animationGroups(); //loop through all imported animation groups and copy the animation curve data to an array. var animations = new Animation[importedAnimGroups.Length]; for (var i = 0; i < importedAnimGroups.Length; i++) { await importedAnimGroups[i].stop(); animations[i] = await(await importedAnimGroups[i].get_targetedAnimations())[0].get_animation(); await importedAnimGroups[i].dispose(); } //create a new animation group and add targeted animations based on copied curve data from the "animations" array. var cannonAnimGroup = await AnimationGroup.NewAnimationGroup( "cannonAnimGroup" ); await cannonAnimGroup.addTargetedAnimation( animations[0], (await cannon.getChildMeshes())[1] ); await cannonAnimGroup.addTargetedAnimation( animations[1], (await cannon.getChildMeshes())[0] ); //create a box for particle emission, position it at the muzzle of the cannon, turn off visibility and parent it to the cannon mesh var particleEmitter = await MeshBuilder.CreateBox( "particleEmitter", new { size = 0.05 }, scene ); await particleEmitter.set_position(await Vector3.NewVector3( 0, 0.76m, 1.05m )); await(await particleEmitter.get_rotation()).set_x(await Tools.ToRadians(78.5m)); await particleEmitter.set_isVisible(false); await particleEmitter.setParent( (await cannon.getChildMeshes())[1] ); //load particle system from the snippet server and set the emitter to the particleEmitter. Set its stopDuration. var baseurl = await Tools.get_BaseUrl(); var snippetUrl = await ParticleHelper.get_SnippetUrl(); var smokeBlast = await ParticleHelper.CreateFromSnippetAsync( "LCBQ5Y#6", scene, false, await ParticleHelper.get_SnippetUrl() ); await smokeBlast.set_emitter(particleEmitter); await smokeBlast.set_targetStopDuration(0.2m); //load a cannon blast sound var cannonBlastSound = await Sound.NewSound( "music", "https://assets.babylonjs.com/sound/cannonBlast.mp3", scene ); //position and rotation data for the placement of the cannon clones var cannonPositionArray = new Vector3[][] { new Vector3[] { await Vector3.NewVector3(0.97m, 5.52m, 1.79m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(0), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(1.08m, 2.32m, 3.05m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(0), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(1.46m, 2.35m, -0.73m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(90), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(1.45m, 5.52m, -1.66m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(90), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(1.49m, 8.69m, -0.35m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(90), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(-1.37m, 8.69m, -0.39m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(-90), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(0.58m, 4, -2.18m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(180), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(1.22m, 8.69m, -2.5m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(180), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(-1.31m, 2.33m, -2.45m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(180), await Tools.ToRadians(180)) }, new Vector3[] { await Vector3.NewVector3(-3.54m, 5.26m, -2.12m), await Vector3.NewVector3(await Tools.ToRadians(0), await Tools.ToRadians(-90), await Tools.ToRadians(180)) } }; //create 10 cannon clones, each with unique position/rotation data. Note that particle systems are cloned with parent meshes //also create 10 new animation groups with targeted animations applied to the newly cloned meshes for (var i = 0; i < 10; i++) { var cannonClone = await cannon.clone <AbstractMesh>( "cannonClone" + i ); await cannonClone.set_position(cannonPositionArray[i][0]); await cannonClone.set_rotation(cannonPositionArray[i][1]); var cannonAnimGroupClone = await AnimationGroup.NewAnimationGroup( "cannonAnimGroupClone" + i ); await cannonAnimGroupClone.addTargetedAnimation( await (await cannonAnimGroup.get_targetedAnimations())[0].get_animation(), (await cannonClone.getChildMeshes())[1]); await cannonAnimGroupClone.addTargetedAnimation( await (await cannonAnimGroup.get_targetedAnimations())[1].get_animation(), (await cannonClone.getChildMeshes())[0]); //store a key/value pair of each clone name and the name of the associated animation group name. cannonAnimationPairings[await cannonClone.get_name()] = await cannonAnimGroupClone.get_name(); //store key/value pair for the cannon name and it's readyToPlay status as 1; cannonReadyToPlay[await cannonClone.get_name()] = 1; } //dispose of the original cannon, animation group, and particle system await cannon.dispose(); await cannonAnimGroup.dispose(); await smokeBlast.dispose(); //create an array for all particle systems in the scene, loop through it and stop all systems from playing. var smokeBlasts = await scene.get_particleSystems(); for (var i = 0; i < smokeBlasts.Length; i++) { await smokeBlasts[i].stop(); } //logic of what happens on a click await(await scene.get_onPointerObservable()).add(async(pointerInfo, eventState) => { // PointerEventTypes.POINTERDOWN if (await pointerInfo.get_type() != 1) { return; } var pickResult = await pointerInfo.get_pickInfo(); //check if a mesh was picked and if that mesh has specific metadata var pickedMesh = await pickResult.get_pickedMesh(); if (pickedMesh != null && await pickedMesh.get_metadata() != null) { var metadataNode = (await pickedMesh.get_metadata()).ToEntity <NodeMetadata>(); if (await metadataNode.get_name() != "cannon") { return; } //find the top level parent (necessary since the cannon is an extra layer below the clone root) var topParent = await(await pickResult.get_pickedMesh()).get_parent(); var parent = await topParent.get_parent(); if (parent != null && await parent.get_name() != null) { topParent = parent; } var name = await topParent.get_name(); //wrap all 'play' elements into a check to make sure the cannon can be played. if (cannonReadyToPlay[name] == 1) { //set the readyToPlay status to 0 cannonReadyToPlay[name] = 0; //loop through all of the animation groups in the scene and play the correct group based on the top level parent of the picked mesh. var animationToPlay = cannonAnimationPairings[name]; for (var i = 0; i < (await scene.get_animationGroups()).Length; i++) { if (await(await scene.get_animationGroups())[i].get_name() == animationToPlay) { await(await scene.get_animationGroups())[i].play(); //after the animation has finished, set the readyToPlay status for this cannon to 1; await(await(await scene.get_animationGroups())[i].get_onAnimationGroupEndObservable()).addOnce(async(_, __) => { cannonReadyToPlay[await topParent.get_name()] = 1; }); } } //loop through all particle systems in the scene, loop through all picked mesh submeshes. if there is a matching mesh and particle system emitter, start the particle system. var childMeshes = await(await pickResult.get_pickedMesh()).getChildMeshes(); for (var i = 0; i < smokeBlasts.Length; i++) { for (var j = 0; j < childMeshes.Length; j++) { if (childMeshes[j].___guid == (await smokeBlasts[i].get_emitter()).___guid) { await smokeBlasts[i].start(); } } } await cannonBlastSound.play(); } } }); //scene.onPointerDown = function(evt, pickResult) { // //check if a mesh was picked and if that mesh has specific metadata // if (pickResult.pickedMesh && pickResult.pickedMesh.metadata === "cannon") // { // //find the top level parent (necessary since the cannon is an extra layer below the clone root) // var topParent = pickResult.pickedMesh.parent; // if (topParent.parent) // { // topParent = topParent.parent; // } // //wrap all 'play' elements into a check to make sure the cannon can be played. // if (cannonReadyToPlay[topParent.name] === 1) // { // //set the readyToPlay status to 0 // cannonReadyToPlay[topParent.name] = 0; // //loop through all of the animation groups in the scene and play the correct group based on the top level parent of the picked mesh. // var animationToPlay = cannonAnimationPairings[topParent.name]; // for (var i = 0; i < scene.animationGroups.length; i++) // { // if (scene.animationGroups[i].name === animationToPlay) // { // scene.animationGroups[i].play(); // //after the animation has finished, set the readyToPlay status for this cannon to 1; // scene.animationGroups[i].onAnimationGroupEndObservable.addOnce(() => // { // cannonReadyToPlay[topParent.name] = 1; // }); // } // } // //loop through all particle systems in the scene, loop through all picked mesh submeshes. if there is a matching mesh and particle system emitter, start the particle system. // var childMeshes = pickResult.pickedMesh.getChildMeshes(); // for (var i = 0; i < smokeBlasts.length; i++) // { // for (var j = 0; j < childMeshes.length; j++) // { // if (childMeshes[j] === smokeBlasts[i].emitter) // { // smokeBlasts[i].start(); // } // } // } // cannonBlastSound.play(); // } // } //}; _scene = scene; await _scene.set_activeCamera(camera); await engine.runRenderLoop(new ActionCallback( () => Task.Run(() => _scene.render(true, false)) )); _engine = engine; }
protected bool Equals(NodeMetadata other) { return(string.Equals(Id, other.Id)); }