Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    TypeError
Message:      Couldn't cast array of type
struct<content_hash: string, timestamp: string, source: string, line_count: int64, max_line_length: int64, avg_line_length: double, alnum_prop: double, repo_name: string, id: string, size: string, binary: bool, copies: string, ref: string, path: string, mode: string, license: string, language: list<item: struct<name: string, bytes: string>>, symlink_target: string>
to
{'content_hash': Value(dtype='string', id=None), 'timestamp': Value(dtype='string', id=None), 'source': Value(dtype='string', id=None), 'line_count': Value(dtype='int64', id=None), 'max_line_length': Value(dtype='int64', id=None), 'avg_line_length': Value(dtype='float64', id=None), 'alnum_prop': Value(dtype='float64', id=None), 'repo_name': Value(dtype='string', id=None), 'id': Value(dtype='string', id=None), 'size': Value(dtype='string', id=None), 'binary': Value(dtype='bool', id=None), 'copies': Value(dtype='string', id=None), 'ref': Value(dtype='string', id=None), 'path': Value(dtype='string', id=None), 'mode': Value(dtype='string', id=None), 'license': Value(dtype='string', id=None), 'language': [{'name': Value(dtype='string', id=None), 'bytes': Value(dtype='string', id=None)}]}
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2011, in _prepare_split_single
                  writer.write_table(table)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 585, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2302, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2261, in cast_table_to_schema
                  arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()]
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2261, in <listcomp>
                  arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()]
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1802, in wrapper
                  return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1802, in <listcomp>
                  return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2122, in cast_array_to_feature
                  raise TypeError(f"Couldn't cast array of type\n{_short_str(array.type)}\nto\n{_short_str(feature)}")
              TypeError: Couldn't cast array of type
              struct<content_hash: string, timestamp: string, source: string, line_count: int64, max_line_length: int64, avg_line_length: double, alnum_prop: double, repo_name: string, id: string, size: string, binary: bool, copies: string, ref: string, path: string, mode: string, license: string, language: list<item: struct<name: string, bytes: string>>, symlink_target: string>
              to
              {'content_hash': Value(dtype='string', id=None), 'timestamp': Value(dtype='string', id=None), 'source': Value(dtype='string', id=None), 'line_count': Value(dtype='int64', id=None), 'max_line_length': Value(dtype='int64', id=None), 'avg_line_length': Value(dtype='float64', id=None), 'alnum_prop': Value(dtype='float64', id=None), 'repo_name': Value(dtype='string', id=None), 'id': Value(dtype='string', id=None), 'size': Value(dtype='string', id=None), 'binary': Value(dtype='bool', id=None), 'copies': Value(dtype='string', id=None), 'ref': Value(dtype='string', id=None), 'path': Value(dtype='string', id=None), 'mode': Value(dtype='string', id=None), 'license': Value(dtype='string', id=None), 'language': [{'name': Value(dtype='string', id=None), 'bytes': Value(dtype='string', id=None)}]}
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1529, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1154, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2038, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

text
string
meta
dict
<?php namespace SPHERE\Application\People\Person; use SPHERE\Application\IApplicationInterface; use SPHERE\Application\IModuleInterface; use SPHERE\Application\Platform\Gatekeeper\Authorization\Consumer\Consumer; use SPHERE\Common\Main; use SPHERE\Common\Window\Navigation\Link; use SPHERE\System\Database\Link\Identifier; /** * Class Person * * @package SPHERE\Application\People\Person */ class Person implements IApplicationInterface, IModuleInterface { public static function registerApplication() { self::registerModule(); Main::getDisplay()->addApplicationNavigation( new Link(new Link\Route(__NAMESPACE__), new Link\Name('Person'), new Link\Icon(new \SPHERE\Common\Frontend\Icon\Repository\Person()) ) ); } public static function registerModule() { Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__, 'Frontend::frontendPerson' )); // Contact: Address Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Address/Create', 'SPHERE\Application\Contact\Address\Frontend::frontendCreateToPerson' ) ->setParameterDefault('Street', null) ->setParameterDefault('City', null) ->setParameterDefault('State', null) ->setParameterDefault('Type', null) ); Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Address/Destroy', 'SPHERE\Application\Contact\Address\Frontend::frontendDestroyToPerson' ) ->setParameterDefault('Id', null) ->setParameterDefault('Confirm', false) ); // Contact: Mail Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Mail/Create', 'SPHERE\Application\Contact\Mail\Frontend::frontendCreateToPerson' ) ->setParameterDefault('Address', null) ->setParameterDefault('Type', null) ); Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Mail/Edit', 'SPHERE\Application\Contact\Mail\Frontend::frontendUpdateToPerson' ) ->setParameterDefault('Address', null) ->setParameterDefault('Type', null) ); Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Mail/Destroy', 'SPHERE\Application\Contact\Mail\Frontend::frontendDestroyToPerson' ) ->setParameterDefault('Id', null) ->setParameterDefault('Confirm', false) ); // Contact: Phone Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Phone/Create', 'SPHERE\Application\Contact\Phone\Frontend::frontendCreateToPerson' ) ->setParameterDefault('Number', null) ->setParameterDefault('Type', null) ); Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Phone/Destroy', 'SPHERE\Application\Contact\Phone\Frontend::frontendDestroyToPerson' ) ->setParameterDefault('Id', null) ->setParameterDefault('Confirm', false) ); // People: Relationship Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Relationship/Create', 'SPHERE\Application\People\Relationship\Frontend::frontendCreateToPerson' ) ->setParameterDefault('To', null) ->setParameterDefault('Type', null) ); Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute( __NAMESPACE__.'/Relationship/Destroy', 'SPHERE\Application\People\Relationship\Frontend::frontendDestroyToPerson' ) ->setParameterDefault('Id', null) ->setParameterDefault('Confirm', false) ); } /** * @return Service */ public static function useService() { return new Service( new Identifier('People', 'Person', null, null, Consumer::useService()->getConsumerBySession()), __DIR__.'/Service/Entity', __NAMESPACE__.'\Service\Entity' ); } /** * @return Frontend */ public static function useFrontend() { return new Frontend(); } }
{ "content_hash": "9798b52e35a59ba643619396055f0531", "timestamp": "", "source": "github", "line_count": 124, "max_line_length": 116, "avg_line_length": 36.36290322580645, "alnum_prop": 0.6225327123530716, "repo_name": "TheTypoMaster/SPHERE-Framework", "id": "0128a2a3cb4a207dc73b79db82b253bc628c4da5", "size": "4509", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "Application/People/Person/Person.php", "mode": "33188", "license": "bsd-2-clause", "language": [ { "name": "ApacheConf", "bytes": "2630" }, { "name": "Batchfile", "bytes": "7341" }, { "name": "CSS", "bytes": "1047983" }, { "name": "HTML", "bytes": "6258719" }, { "name": "JavaScript", "bytes": "15888113" }, { "name": "Makefile", "bytes": "6774" }, { "name": "PHP", "bytes": "9320934" }, { "name": "PowerShell", "bytes": "149" }, { "name": "Python", "bytes": "22027" }, { "name": "Ruby", "bytes": "2399" }, { "name": "Shell", "bytes": "6738" }, { "name": "Smarty", "bytes": "65319" } ] }
import sortObject from 'deep-sort-object' const manifestPropOrder = [ 'name', 'private', 'version', 'description', 'main', 'author', 'license', 'scripts', 'keywords', 'dependencies', 'devDependencies' ] function getCommonManifest(data) { const pkg = { name: data.name, version: '1.0.0', description: data.description, author: data.author, license: data.license, devDependencies: {} } if (pkg.license === 'UNLICENSED') { pkg.private = true } if (data.gitRemote) { pkg.repository = { type: 'git', url: data.gitRemote } } return pkg } export function createPackageManifest(data) { const deps = data.dependencies ? {dependencies: sortObject(data.dependencies)} : {} const pkg = Object.assign( getCommonManifest(data), { main: 'package.json', keywords: ['lyra'], scripts: { start: 'lyra start', test: 'lyra check' } }, deps ) return serializeManifest(pkg) } export function createPluginManifest(data, opts = {}) { const pkg = Object.assign(getCommonManifest(data), { main: 'src/plugin.js', scripts: {test: 'echo "Error: no test specified" && exit 1'}, keywords: ['lyra', 'lyra-plugin'], dependencies: {} }) return serializeManifest(pkg) } function getLyraPluginManifest(data, {isLyraStyle}) { const prefix = data.name.replace(/^lyra-plugin-/, '') if (isLyraStyle) { return { paths: { source: './src', compiled: './lib' }, parts: [ { name: `part:${prefix}/my-component`, path: 'MyComponent.js' } ] } } return { parts: [ { implements: `part:${prefix}/my-component`, description: 'Description for this role. Change `implements` to `name` if it should be non-overridable.', path: 'lib/MyComponent.js' } ] } } export function createLyraManifest(data, opts) { let manifest if (opts.isPlugin) { manifest = getLyraPluginManifest(data, opts) } else { manifest = { root: true, project: { name: data.displayName }, api: { apiHost: data.apiHost, dataset: data.defaultVenueDataset, token: data.provisionalToken || undefined }, venues: [{_id: data.defaultVenueDataset, title: data.defaultVenueName}], plugins: [ '@lyra/base', '@lyra/components', '@lyra/default-login', '@lyra/google-maps-input', '@lyra/form-builder', '@vega/core', '@vega/components', '@vega/layout', '@vega/theme', '@vega/communicator-system', '@vega/issues-tool', '@vega/tracks-tool', '@vega/composer-tool', '@vega/submissions-tool', '@vega/review-tool', '@vega/article-state-tool', '@vega/feature-checklist', '@vega/feature-declaration', '@vega/feature-due-date', '@vega/feature-notifier', '@lyra/desk-tool' ], parts: [ { name: 'part:@lyra/base/schema', path: './schemas/schema.js' } ] } } return opts.serialize ? `${JSON.stringify(manifest, null, 2)}\n` : manifest } function serializeManifest(src) { const props = manifestPropOrder.concat(Object.keys(src)) const ordered = props.reduce((target, prop) => { if ( typeof src[prop] !== 'undefined' && typeof target[prop] === 'undefined' ) { target[prop] = src[prop] } return target }, {}) return `${JSON.stringify(ordered, null, 2)}\n` }
{ "content_hash": "71a1e86aa11dd53eb6d0c4f63ff1d67b", "timestamp": "", "source": "github", "line_count": 172, "max_line_length": 102, "avg_line_length": 21.191860465116278, "alnum_prop": 0.5640603566529493, "repo_name": "VegaPublish/vega-studio", "id": "20567e41b4cdfad57af6334a59e20ca3b1944174", "size": "3645", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "packages/@lyra/cli/src/actions/init-project/createManifest.js", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "34288" }, { "name": "JavaScript", "bytes": "224534" } ] }
using Game.Renderer; using Game.Utils; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Game { public partial class MainMenu : Form { public MainMenu() { InitializeComponent(); } private void newGameBtn_Click(object sender, EventArgs e) { new Game(new Board(), new WindowsFormsRenderer()).Show(); this.Hide(); } private void mainMenuQuitBtn_Click(object sender, EventArgs e) { Application.Exit(); } private void MainMenu_Load(object sender, EventArgs e) { this.Location = new Point(0, 0); this.Size = Screen.PrimaryScreen.WorkingArea.Size; newGameBtn.Left = (this.ClientSize.Width - newGameBtn.Width) / 2; mainMenuCreditsBtn.Left = (this.ClientSize.Width - mainMenuCreditsBtn.Width) / 2; mainMenuQuitBtn.Left = (this.ClientSize.Width - mainMenuCreditsBtn.Width) / 2; } } }
{ "content_hash": "f5820d7d736a0f245b13ec91ecd1eeba", "timestamp": "", "source": "github", "line_count": 44, "max_line_length": 93, "avg_line_length": 27.613636363636363, "alnum_prop": 0.6041152263374485, "repo_name": "TDMYF/TowerDefence", "id": "fa7797fde40d11de605fdfcd72a030bc3d01d42a", "size": "1217", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "Game/Forms/MainMenu.cs", "mode": "33188", "license": "mit", "language": [ { "name": "C#", "bytes": "22339" } ] }
package org.apache.camel.component.jms; import javax.jms.ConnectionFactory; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; /** * @version $Revision$ */ public class JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest extends CamelTestSupport { protected String componentName = "activemq"; @Test public void testRequestReplyWithConcurrent() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(5); log.info("Sending messages ..."); template.sendBody("seda:start", "A"); template.sendBody("seda:start", "B"); template.sendBody("seda:start", "C"); template.sendBody("seda:start", "D"); template.sendBody("seda:start", "E"); log.info("... done sending messages"); assertMockEndpointsSatisfied(); } protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); camelContext.addComponent(componentName, jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("seda:start") .inOut().to("activemq:queue:foo") .log("reply - ${body}") .threads(5) .log("delay - ${body}") .delay(2000) .log("done - ${body}") .to("mock:result"); from("activemq:queue:foo") .log("request - ${body}") .transform(body().prepend("Bye ")) .to("mock:bye"); } }; } }
{ "content_hash": "92b9627a8135df67f1c34f6c6c1e6e68", "timestamp": "", "source": "github", "line_count": 69, "max_line_length": 97, "avg_line_length": 31.971014492753625, "alnum_prop": 0.6155938349954669, "repo_name": "kingargyle/turmeric-bot", "id": "c1baf5cb57097a9fee605c6b6a8881a75a1daabd", "size": "3009", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyProcessRepliesConcurrentUsingThreadsTest.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "ActionScript", "bytes": "20202" }, { "name": "Batchfile", "bytes": "108" }, { "name": "CSS", "bytes": "220587" }, { "name": "FreeMarker", "bytes": "11350" }, { "name": "Groovy", "bytes": "2711" }, { "name": "HTML", "bytes": "308151" }, { "name": "Java", "bytes": "19316639" }, { "name": "JavaScript", "bytes": "4172468" }, { "name": "PHP", "bytes": "88860" }, { "name": "Protocol Buffer", "bytes": "578" }, { "name": "Ruby", "bytes": "4814" }, { "name": "Scala", "bytes": "185055" }, { "name": "Shell", "bytes": "351" }, { "name": "Tcl", "bytes": "2969" }, { "name": "XQuery", "bytes": "332" }, { "name": "XSLT", "bytes": "37282" } ] }
extern crate scoped_stateful_threadpool; use scoped_stateful_threadpool::Pool; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT}; use std::panic::AssertUnwindSafe; // The representation invariant for PositivelyAtomic is that it is // always a positive integer. When we drop it, we store zero in // its value; but one should never observe that. pub struct PositivelyAtomic(AtomicUsize); impl Drop for PositivelyAtomic { fn drop(&mut self) { // Since we are being dropped, we will now break the // representation invariant. (And then clients will // subsequently observe that breakage.) self.0.store(0, Ordering::Relaxed); } } impl PositivelyAtomic { pub fn new(x: usize) -> PositivelyAtomic { assert!(x > 0); PositivelyAtomic(AtomicUsize::new(x)) } // Assuming the representation invariant holds, this should // always return a positive value. pub fn load(&self) -> usize { self.0.load(Ordering::Relaxed) } pub fn cas(&self, old: usize, new: usize) -> usize { assert!(new > 0); self.0.compare_and_swap(old, new, Ordering::Relaxed) } } #[test] fn demo_stack_allocated() { static SAW_ZERO: AtomicBool = ATOMIC_BOOL_INIT; for _i in 0..100 { let saw_zero = &AssertUnwindSafe(&SAW_ZERO); let _p = ::std::panic::catch_unwind(move || { let p = PositivelyAtomic::new(1); kernel(&p, saw_zero); }); if saw_zero.load(Ordering::Relaxed) { panic!("demo_stack_allocated saw zero!"); } } } #[test] fn demo_heap_allocated() { static SAW_ZERO: AtomicBool = ATOMIC_BOOL_INIT; for i in 0..100 { let saw_zero = &AssertUnwindSafe(&SAW_ZERO); let _p = ::std::panic::catch_unwind(move || { let mut v = Vec::with_capacity((i % 5)*1024 + i); v.push(PositivelyAtomic::new(1)); kernel(&v[0], saw_zero); }); if saw_zero.load(Ordering::Relaxed) { panic!("demo_heap_allocated saw zero!"); } } } pub fn kernel(r: &PositivelyAtomic, saw_zero: &AtomicBool) { // Create a threadpool holding 4 threads let mut pool = Pool::new(4, &|| ()); // Use the threads as scoped threads that can // reference anything outside this closure pool.scoped(|scope| { // Create references to each element in the vector ... for _ in 0..4 { scope.execute(move |_| { for _ in 0..100000 { let v = r.load(); if v == 0 { saw_zero.store(true, Ordering::Relaxed); panic!("SAW ZERO"); } let v_new = (v % 100) + 1; if v != r.cas(v, v_new) { // this is not a true panic condition // in the original scenario. // // it rather is a rare event, and I want to // emulate a rare panic occurring from one // thread (and then see how the overall // computation proceeds from there). panic!("interference"); } else { // incremented successfully } } }); } }); }
{ "content_hash": "4adee042f2626b26d97ed299433b537d", "timestamp": "", "source": "github", "line_count": 103, "max_line_length": 67, "avg_line_length": 33.56310679611651, "alnum_prop": 0.5319641307492046, "repo_name": "njaard/scoped-stateful-threadpool-rs", "id": "f082be8032f2bb6aa72b749631de8ea489afbb2b", "size": "3457", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "tests/threads-living-too-long-demo.rs", "mode": "33188", "license": "mit", "language": [ { "name": "Rust", "bytes": "20251" } ] }
package eu.lunisolar.magma.func.build.function.from; import eu.lunisolar.magma.basics.Null; import eu.lunisolar.magma.func.build.*; import eu.lunisolar.magma.func.Function4U; // NOSONAR import eu.lunisolar.magma.basics.builder.*; // NOSONAR import javax.annotation.Nonnull; // NOSONAR import javax.annotation.Nullable; // NOSONAR import eu.lunisolar.magma.basics.exceptions.*; // NOSONAR import eu.lunisolar.magma.basics.meta.*; // NOSONAR import eu.lunisolar.magma.basics.meta.functional.*; // NOSONAR import eu.lunisolar.magma.basics.meta.functional.type.*; // NOSONAR import eu.lunisolar.magma.basics.meta.functional.domain.*; // NOSONAR import java.util.function.*; import eu.lunisolar.magma.func.action.*; // NOSONAR import eu.lunisolar.magma.func.consumer.*; // NOSONAR import eu.lunisolar.magma.func.consumer.primitives.*; // NOSONAR import eu.lunisolar.magma.func.consumer.primitives.bi.*; // NOSONAR import eu.lunisolar.magma.func.consumer.primitives.obj.*; // NOSONAR import eu.lunisolar.magma.func.consumer.primitives.tri.*; // NOSONAR import eu.lunisolar.magma.func.function.*; // NOSONAR import eu.lunisolar.magma.func.function.conversion.*; // NOSONAR import eu.lunisolar.magma.func.function.from.*; // NOSONAR import eu.lunisolar.magma.func.function.to.*; // NOSONAR import eu.lunisolar.magma.func.operator.binary.*; // NOSONAR import eu.lunisolar.magma.func.operator.ternary.*; // NOSONAR import eu.lunisolar.magma.func.operator.unary.*; // NOSONAR import eu.lunisolar.magma.func.predicate.*; // NOSONAR import eu.lunisolar.magma.func.supplier.*; // NOSONAR /** * Builder for LObjFltFunction. */ public final class LObjFltFunctionBuilder<T, R> extends PerCaseBuilderWithProduct.Base<LObjFltFunctionBuilder<T, R>, LObjFltPredicate<T>, LObjFltFunction<T, R>, R> { // extends PER_CASE_BUILDER<BUILDER_NAME func.B(the_case.class_args_ref), CASE_PREDICATE func.B(the_case.domain_class_argsX_ref), the_case.name_ref RRR> { private Consumer<LObjFltFunction<T, R>> consumer; private @Nullable HandlingInstructions handling; public static final LObjFltFunction OTHERWISE_THROW = LObjFltFunction.objFltFunc((a1, a2) -> { throw new IllegalStateException("There is no case configured for the arguments (if any)."); }); public LObjFltFunctionBuilder(@Nullable Consumer<LObjFltFunction<T, R>> consumer) { super(OTHERWISE_THROW, LObjFltFunction::constant, () -> new LObjFltFunctionBuilder(null)); this.consumer = consumer; } /** One of ways of creating builder. In most cases (considering all _functional_ builders) it requires to provide generic parameters (in most cases redundantly) */ public LObjFltFunctionBuilder() { this(null); } /** One of ways of creating builder. In most cases (considering all _functional_ builders) it requires to provide generic parameters (in most cases redundantly) */ @Nonnull public static <T, R> LObjFltFunctionBuilder<T, R> objFltFunction() { return new LObjFltFunctionBuilder(); } /** One of ways of creating builder. This is possibly the least verbose way where compiler should be able to guess the generic parameters. */ @Nonnull public static <T, R> LObjFltFunction<T, R> objFltFunctionFrom(Consumer<LObjFltFunctionBuilder<T, R>> buildingFunction) { LObjFltFunctionBuilder builder = new LObjFltFunctionBuilder(); buildingFunction.accept(builder); return builder.build(); } /** One of ways of creating builder. This might be the only way (considering all _functional_ builders) that might be utilize to specify generic params only once. */ @Nonnull public static <T, R> LObjFltFunctionBuilder<T, R> objFltFunction(Consumer<LObjFltFunction<T, R>> consumer) { return new LObjFltFunctionBuilder(consumer); } /** One of ways of creating builder. In most cases (considering all _functional_ builders) it requires to provide generic parameters (in most cases redundantly) */ @Nonnull public final LObjFltFunctionBuilder<T, R> withHandling(@Nonnull HandlingInstructions<Throwable, RuntimeException> handling) { Null.nonNullArg(handling, "handling"); if (this.handling != null) { throw new UnsupportedOperationException("Handling is already set for this builder."); } this.handling = handling; return fluentCtx(); } /** Allows to specify additional cases for a specific type of generic arguments (matched by instanceOf). Null classes can be provided in case of arguments that do not matter. */ @Nonnull public <V extends T> LObjFltFunctionBuilder<T, R> casesOf(Class<V> argC1, Consumer<LObjFltFunctionBuilder<V, R>> pcpConsumer) { PartialCaseWithProduct.The pc = partialCaseFactoryMethod((a1, a2) -> (argC1 == null || argC1.isInstance(a1))); pc.specifySubCases((Consumer) pcpConsumer); return fluentCtx(); } /** Adds full new case for the argument that are of specific classes (matched by instanceOf, null is a wildcard). */ @Nonnull public <V extends T> LObjFltFunctionBuilder<T, R> aCase(Class<V> argC1, LObjFltFunction<V, R> function) { PartialCaseWithProduct.The pc = partialCaseFactoryMethod((a1, a2) -> (argC1 == null || argC1.isInstance(a1))); pc.evaluate(function); return fluentCtx(); } /** Builds the functional interface implementation and if previously provided calls the consumer. */ @Nonnull public final LObjFltFunction<T, R> build() { final LObjFltFunction<T, R> otherwiseFinal = this.otherwise; LObjFltFunction<T, R> retval; final Case<LObjFltPredicate<T>, LObjFltFunction<T, R>>[] casesArray = cases.toArray(new Case[cases.size()]); retval = LObjFltFunction.<T, R> objFltFunc((a1, a2) -> { try { for (Case<LObjFltPredicate<T>, LObjFltFunction<T, R>> aCase : casesArray) { if (aCase.casePredicate().test(a1, a2)) { return aCase.caseFunction().apply(a1, a2); } } return otherwiseFinal.apply(a1, a2); } catch (Error e) { // NOSONAR throw e; } catch (Throwable e) { // NOSONAR throw Handler.handleOrPropagate(e, handling); } }); if (consumer != null) { consumer.accept(retval); } return retval; } public final LObjFltFunction<T, R> build(@Nonnull HandlingInstructions<Throwable, RuntimeException> handling) { this.withHandling(handling); return build(); } }
{ "content_hash": "137d450c255e26ff7efa9544c12be50d", "timestamp": "", "source": "github", "line_count": 144, "max_line_length": 178, "avg_line_length": 43, "alnum_prop": 0.7461240310077519, "repo_name": "lunisolar/magma", "id": "dc6252e81a6c8d2fce0bcc8f919055b86c502d82", "size": "6863", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "magma-func-builder/src/main/java/eu/lunisolar/magma/func/build/function/from/LObjFltFunctionBuilder.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "Java", "bytes": "23031222" } ] }
/** * @description * * A humpback-view created at Sun Sep 13 2015 21:29:15 GMT-0400 (EDT). */ angular.module( 'humpback.views.AdminDataViewView.states', [ ]) .config(function config( $stateProvider, $urlRouterProvider) { $stateProvider .state( 'admin.data.data.data', { url: '/:model/view/:item', ncyBreadcrumb: { label: 'Item' }, views: { "content@admin.data.data": { controller: 'AdminDataViewViewCtrl', templateUrl: 'app/views/admin/data/view/view/index.html' }, "widgets@admin.data.data.data": { templateUrl: 'app/views/admin/data/view/view/widgets.html' } } }) .state( 'admin.data.data.new', { url: '/:model/new?id', ncyBreadcrumb: { label: 'New Item' }, views: { "content@admin.data.data": { controller: 'AdminDataViewNewCtrl', templateUrl: 'app/views/admin/data/view/view/index.html' }, "widgets@admin.data.data.new": { templateUrl: 'app/views/admin/data/view/view/widgets.html' } } }) ; });
{ "content_hash": "25d02378adf76fc831d7c153760439f7", "timestamp": "", "source": "github", "line_count": 43, "max_line_length": 70, "avg_line_length": 24.25581395348837, "alnum_prop": 0.6078619367209971, "repo_name": "CaliStyle/humpback", "id": "8157d0995a391cf0f1579a2baf88dc75a2ca5ed2", "size": "1043", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "assets/app/views/admin/data/view/view/AdminDataViewView.states.js", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "27967" }, { "name": "HTML", "bytes": "125488" }, { "name": "JavaScript", "bytes": "272879" } ] }
ACCEPTED #### According to International Plant Names Index #### Published in null #### Original name null ### Remarks null
{ "content_hash": "8798b45ae64e4395d6ec31c20cbb4087", "timestamp": "", "source": "github", "line_count": 13, "max_line_length": 31, "avg_line_length": 9.692307692307692, "alnum_prop": 0.7063492063492064, "repo_name": "mdoering/backbone", "id": "dbe56ce5647c5a67647f5c991cab1d2e99fe63b5", "size": "179", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "life/Plantae/Magnoliophyta/Magnoliopsida/Ericales/Primulaceae/Lysimachia/Lysimachia pseudohenryi/README.md", "mode": "33188", "license": "apache-2.0", "language": [] }
import { HttpClientUtility } from '../src/facilityCore'; import { expect, should } from 'chai'; should(); const createResponseError = HttpClientUtility.createResponseError; describe('createResponseError', () => { it('should return json with code', () => { createResponseError(500, { 'code': 'heyNow' }) .should.deep.equal({ 'error': { 'code': 'heyNow' } }); }); it('should return json with code on any status', () => { createResponseError(200, { 'code': 'heyNow' }) .should.deep.equal({ 'error': { 'code': 'heyNow' } }); }); it('should return custom error with no code', () => { createResponseError(500, { 'message': 'heyNow' }) .should.deep.equal({ 'error': { 'code': 'InternalError', 'message': 'HTTP server error: 500' } }); }); it('should return custom error with no JSON', () => { createResponseError(500) .should.deep.equal({ 'error': { 'code': 'InternalError', 'message': 'HTTP server error: 500' } }); }); it('should return invalid response with weird server error', () => { createResponseError(599) .should.deep.equal({ 'error': { 'code': 'InvalidResponse', 'message': 'HTTP server error: 599' } }); }); it('should return invalid request with weird client error', () => { createResponseError(499) .should.deep.equal({ 'error': { 'code': 'InvalidRequest', 'message': 'HTTP client error: 499' } }); }); it('should return invalid response with success', () => { createResponseError(200) .should.deep.equal({ 'error': { 'code': 'InvalidResponse', 'message': 'Unexpected HTTP status code: 200' } }); }); });
{ "content_hash": "8199fc62023d5b20b8fa9fdbd0e7a259", "timestamp": "", "source": "github", "line_count": 45, "max_line_length": 113, "avg_line_length": 34.93333333333333, "alnum_prop": 0.6374045801526718, "repo_name": "FacilityApi/FacilityJavaScript", "id": "fbe21eac504dfaccd0432928792d720f77888305", "size": "1572", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "ts/test/createResponseError.ts", "mode": "33188", "license": "mit", "language": [ { "name": "C#", "bytes": "38232" }, { "name": "JavaScript", "bytes": "28653" }, { "name": "PowerShell", "bytes": "672" }, { "name": "TypeScript", "bytes": "75891" } ] }
package com.microsoft.bingads.v12.api.test.entities.ad_group_dsa_target.read; import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import com.microsoft.bingads.internal.functionalinterfaces.Function; import com.microsoft.bingads.v12.api.test.entities.ad_group_dsa_target.BulkAdGroupDynamicSearchAdTargetTest; import com.microsoft.bingads.v12.bulk.entities.BulkAdGroupDynamicSearchAdTarget; import com.microsoft.bingads.v12.campaignmanagement.AdGroupCriterionStatus; @RunWith(Parameterized.class) public class BulkAdGroupDynamicSearchAdTargetReadStatusTest extends BulkAdGroupDynamicSearchAdTargetTest { @Parameter(value = 1) public AdGroupCriterionStatus expectedResult; @Parameters public static Collection<Object[]> data() { return Arrays.asList( new Object[][]{ {"", null}, {null, null}, {"Active", AdGroupCriterionStatus.ACTIVE}, {"Paused", AdGroupCriterionStatus.PAUSED}, {"Deleted", AdGroupCriterionStatus.DELETED} } ); } @Test public void testRead() { testReadProperty( "Status", datum, expectedResult, new Function<BulkAdGroupDynamicSearchAdTarget, AdGroupCriterionStatus>() { @Override public AdGroupCriterionStatus apply(BulkAdGroupDynamicSearchAdTarget c) { return c.getBiddableAdGroupCriterion().getStatus(); } } ); } }
{ "content_hash": "1389e14371048b614aab2338c3ee5842", "timestamp": "", "source": "github", "line_count": 50, "max_line_length": 108, "avg_line_length": 36.34, "alnum_prop": 0.6505228398458999, "repo_name": "bing-ads-sdk/BingAds-Java-SDK", "id": "f8d87d66d9bb29c58d67c6e2dce7d494282f2f96", "size": "1817", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/test/java/com/microsoft/bingads/v12/api/test/entities/ad_group_dsa_target/read/BulkAdGroupDynamicSearchAdTargetReadStatusTest.java", "mode": "33188", "license": "mit", "language": [ { "name": "Batchfile", "bytes": "2059" }, { "name": "Java", "bytes": "9842387" } ] }
require 'rails_helper' RSpec.describe "appointments/create.html.erb", type: :view do pending "add some examples to (or delete) #{__FILE__}" end
{ "content_hash": "c6d7731385a606a48f2c0216257ea1da", "timestamp": "", "source": "github", "line_count": 5, "max_line_length": 61, "avg_line_length": 29.4, "alnum_prop": 0.7142857142857143, "repo_name": "Sebasking01/lookbook", "id": "6e18a167d348de09c9425ff16518e4a27830035f", "size": "147", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "spec/views/appointments/create.html.erb_spec.rb", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "5859" }, { "name": "CoffeeScript", "bytes": "1581" }, { "name": "HTML", "bytes": "16199" }, { "name": "JavaScript", "bytes": "713" }, { "name": "Ruby", "bytes": "55077" } ] }
package printer import ( "fmt" "strings" "github.com/JulzDiverse/aviator" "github.com/starkandwayne/goutils/ansi" ) type Print func(string, ...interface{}) (int, error) func AnsiPrint(opts aviator.MergeConf, to string, warnings []string, verbose bool) { BeautyfulPrint(opts, to, warnings, verbose, ansi.Printf) } func BeautyfulPrint(opts aviator.MergeConf, to string, warnings []string, verbose bool, printf Print) { printf("@G{SPRUCE MERGE:}\n") if len(opts.Prune) != 0 { for _, prune := range opts.Prune { printf("\t@C{--prune} %s\n", prune) } } for _, file := range opts.Files { printf("\t%s\n", file) } printf("\t@G{to: %s}\n\n", to) if verbose && (len(warnings) > 0) { //global variable printf("\t@Y{WARNINGS:}\n") for _, w := range warnings { sl := strings.Split(w, ":") printf("\t@y{%s}:@Y{%s}\n", sl[0], sl[1]) } fmt.Println() fmt.Println() } }
{ "content_hash": "ac0caf6ed39106a61e96e0e0b97b0e57", "timestamp": "", "source": "github", "line_count": 37, "max_line_length": 103, "avg_line_length": 24.216216216216218, "alnum_prop": 0.6316964285714286, "repo_name": "JulzDiverse/aviator", "id": "9fec58b0c6e47d8c6533449dc50db71ad62ec3a2", "size": "896", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "printer/printer.go", "mode": "33188", "license": "mit", "language": [ { "name": "Go", "bytes": "102418" } ] }
layout: default --- <section class="row news"> <nav class="collapsible-menu visible-xs" data-swiftype-index='false'> <button type="button" class="btn btn-nav toggle-menu"> Navigate <span class="caret"></span> </button> <div class="menu hidden"> {% include news_menu.html %} </div> </nav> <div class="col-xs-12 col-sm-9"> {{ content }} </div> <nav class="menu aside hidden-xs hidden-xs col-sm-3" data-swiftype-index='false'> {% include news_menu.html %} </nav> <div class="clear"></div> </section>
{ "content_hash": "09cfe3059fafdc8b11928e328ef563ab", "timestamp": "", "source": "github", "line_count": 24, "max_line_length": 85, "avg_line_length": 25.041666666666668, "alnum_prop": 0.562396006655574, "repo_name": "resthub/resthub.github.io", "id": "8164a351b4a99dc6d094404e8eeba6e6230af928", "size": "605", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "_layouts/news.html", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "265011" }, { "name": "HTML", "bytes": "14909519" }, { "name": "JavaScript", "bytes": "104585" }, { "name": "Ruby", "bytes": "1676" } ] }
<?php namespace SIICBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; use SIICBundle\Entity\Obispo; class ObispoController extends Controller { /* * Sesiones */ private $session; public function __construct() { $this->session = new Session(); } /* * Listado de obispos */ public function viewAllAction(Request $request, $page) { $em = $this->getDoctrine()->getEntityManager(); $informacion_general_repo = $em->getRepository('SIICBundle:Informaciongeneral'); $informacion_general = $informacion_general_repo->findOneBy(array( 'id' => 1 )); $obispo_repo = $em->getRepository('SIICBundle:Obispo'); $tipo_obispo_repo = $em->getRepository('SIICBundle:Tipoobispo'); $tipo_obispos = $tipo_obispo_repo->findBy(array( 'status' => 1 )); $obispos = $obispo_repo->findBy(array( 'status' => 1 )); return $this->render('SIICBundle:Obispo:viewAll.html.twig', array( 'obispos' => $obispos, 'tipo_obispo' => $tipo_obispos, 'page' => $page, 'informacion_general' => $informacion_general, 'curr_page' => 3 )); } /* * Creación de nuevo obispo */ public function addAction(Request $request) { if ($this->getUser() == null || $this->getUser()->getRol() != 'ROLE_ADMIN') { return $this->redirectToRoute("page_not_found"); } $em = $this->getDoctrine()->getEntityManager(); $informacion_general_repo = $em->getRepository('SIICBundle:Informaciongeneral'); $informacion_general = $informacion_general_repo->findOneBy(array( 'id' => 1 )); $tipo_obispo_repo = $em->getRepository('SIICBundle:Tipoobispo'); $jurisdiccion_repo = $em->getRepository('SIICBundle:Jurisdiccion'); $tipo_obispos = $tipo_obispo_repo->findBy(array( 'status'=> 1 )); if ($this->getUser()->getPermisoId() == 0) { $jurisdicciones = $jurisdiccion_repo->findBy(array( 'status'=> 1 )); } else { $jurisdicciones = $jurisdiccion_repo->findBy(array( 'id' => $this->getUser()->getPermisoId(), 'status'=> 1 )); } if ($request->request->get('registrar') != null) { $newObispo = new Obispo(); $tipo_obispo = $tipo_obispo_repo->findOneBy(array( 'id' => $request->request->get('tipoObispo') )); $jurisdiccion = $jurisdiccion_repo->findOneBy(array( 'id' => $request->request->get('jurisdiccion') )); $file = $request->files->get("imagenUrl", null); if ($file != null && !empty($file)) { $ext = $file->guessExtension(); if ($ext == "jpeg" || $ext == "jpg" || $ext == "png") { $file_name = time() . "." . $ext; $path_of_file = "img/obispos/"; $file->move($path_of_file, $file_name); $newObispo->setImagenUrl($path_of_file . $file_name); } else { $newObispo->setImagenUrl('img/userDefault.png'); } } else { $newObispo->setImagenUrl('img/userDefault.png'); } $newObispo->setTipoobispo($tipo_obispo); $newObispo->setJurisdiccion($jurisdiccion); $newObispo->setNombre($request->request->get('nombre')); $newObispo->setApellidoPaterno($request->request->get('apellidoPaterno')); $newObispo->setApellidoMaterno($request->request->get('apellidoMaterno')); $newObispo->setPreTitulo($request->request->get('preTitulo')); $newObispo->setPostTitulo($request->request->get('postTitulo')); $newObispo->setFechaNacimiento(new \DateTime($request->request->get('fechaNacimiento_submit'))); $newObispo->setLugarNacimiento($request->request->get('lugarNacimiento')); $newObispo->setOrdenacionSacerdotal(new \DateTime($request->request->get('ordenacionSacerdotal_submit'))); $newObispo->setOrdenacionEpiscopal(new \DateTime($request->request->get('ordenacionEpiscopal_submit'))); $newObispo->setSedeEpiscopal($request->request->get('sedeEpiscopal')); $newObispo->setDireccion($request->request->get('direccion')); $newObispo->setCasillaPostal($request->request->get('casillaPostal')); $newObispo->setEmail($request->request->get('email')); $newObispo->setTelefono($request->request->get('telefono')); $newObispo->setFax($request->request->get('fax')); $newObispo->setPaginaWeb($request->request->get('paginaWeb')); $newObispo->setEstadoObispo('ACTIVO'); $newObispo->setFbPerfil($request->request->get('facebook')); $newObispo->setTwPerfil($request->request->get('twitter')); $newObispo->setYtPerfil($request->request->get('youtube')); $newObispo->setIgPerfil($request->request->get('instagram')); $newObispo->setBiografia($request->request->get('biografia')); $newObispo->setStatus(true); $newObispo->setCreatedAt(new \DateTime()); $em = $this->getDoctrine()->getEntityManager(); $em->persist($newObispo); $flush = $em->flush(); if ($flush == null) { $status = array( 'message' => 'El obispo se creo correctamente', 'type' => 'success' ); } else { $status = array( 'message' => 'El obispo no pudo ser registrado', 'type' => 'error' ); } $this->session->getFlashBag()->add('status', $status); return $this->redirectToRoute("obispo_view_all"); } return $this->render('SIICBundle:Obispo:add.html.twig', array( 'tipo_obispo' => $tipo_obispos, 'jurisdicciones' => $jurisdicciones, 'informacion_general' => $informacion_general, 'curr_page' => 3 )); } /* * Edicion de obispo */ public function editAction(Request $request, $id) { if ($this->getUser() == null || $this->getUser()->getRol() != 'ROLE_ADMIN' || $this->getUser()->getPermisoId() != 0) { return $this->redirectToRoute("page_not_found"); } $em = $this->getDoctrine()->getEntityManager(); $informacion_general_repo = $em->getRepository('SIICBundle:Informaciongeneral'); $informacion_general = $informacion_general_repo->findOneBy(array( 'id' => 1 )); $tipo_obispo_repo = $em->getRepository('SIICBundle:Tipoobispo'); $jurisdiccion_repo = $em->getRepository('SIICBundle:Jurisdiccion'); $obispo_repo = $em->getRepository('SIICBundle:Obispo'); $tipo_obispos = $tipo_obispo_repo->findBy(array( 'status'=> 1 )); if ($this->getUser()->getPermisoId() == 0) { $jurisdicciones = $jurisdiccion_repo->findBy(array( 'status'=> 1 )); } else { $jurisdicciones = $jurisdiccion_repo->findBy(array( 'id' => $this->getUser()->getPermisoId(), 'status'=> 1 )); } $obispo = $obispo_repo->findOneBy(array( 'id' => $id )); if ($request->request->get('editar') != null) { $tipo_obispo = $tipo_obispo_repo->findOneBy(array( 'id' => $request->request->get('tipoObispo') )); $jurisdiccion = $jurisdiccion_repo->findOneBy(array( 'id' => $request->request->get('jurisdiccion') )); $file = $request->files->get("imagenUrl", null); if ($file != null && !empty($file)) { $ext = $file->guessExtension(); if ($ext == "jpeg" || $ext == "jpg" || $ext == "png") { $file_name = time() . "." . $ext; $path_of_file = "img/obispos/"; $file->move($path_of_file, $file_name); $obispo->setImagenUrl($path_of_file . $file_name); } } $obispo->setTipoobispo($tipo_obispo); $obispo->setJurisdiccion($jurisdiccion); $obispo->setNombre($request->request->get('nombre')); $obispo->setApellidoPaterno($request->request->get('apellidoPaterno')); $obispo->setApellidoMaterno($request->request->get('apellidoMaterno')); $obispo->setPreTitulo($request->request->get('preTitulo')); $obispo->setPostTitulo($request->request->get('postTitulo')); $obispo->setFechaNacimiento(new \DateTime($request->request->get('fechaNacimiento_submit'))); $obispo->setLugarNacimiento($request->request->get('lugarNacimiento')); $obispo->setOrdenacionSacerdotal(new \DateTime($request->request->get('ordenacionSacerdotal_submit'))); $obispo->setOrdenacionEpiscopal(new \DateTime($request->request->get('ordenacionEpiscopal_submit'))); $obispo->setSedeEpiscopal($request->request->get('sedeEpiscopal')); $obispo->setDireccion($request->request->get('direccion')); $obispo->setCasillaPostal($request->request->get('casillaPostal')); $obispo->setEmail($request->request->get('email')); $obispo->setTelefono($request->request->get('telefono')); $obispo->setFax($request->request->get('fax')); $obispo->setPaginaWeb($request->request->get('paginaWeb')); $obispo->setEstadoObispo('ACTIVO'); $obispo->setFbPerfil($request->request->get('facebook')); $obispo->setTwPerfil($request->request->get('twitter')); $obispo->setYtPerfil($request->request->get('youtube')); $obispo->setIgPerfil($request->request->get('instagram')); $obispo->setBiografia($request->request->get('biografia')); $em = $this->getDoctrine()->getEntityManager(); $em->persist($obispo); $flush = $em->flush(); if ($flush == null) { $status = array( 'message' => 'El obispo se editó correctamente', 'type' => 'success' ); } else { $status = array( 'message' => 'El obispo no pudo ser editado', 'type' => 'error' ); } $this->session->getFlashBag()->add('status', $status); return $this->redirectToRoute("obispo_view_all"); } return $this->render('SIICBundle:Obispo:edit.html.twig', array( 'tipo_obispo' => $tipo_obispos, 'jurisdicciones' => $jurisdicciones, 'obispo' => $obispo, 'id' => $id, 'informacion_general' => $informacion_general, 'curr_page' => 3 )); } /* * Eliminado de obispo */ public function deleteAction(Request $request, $id) { if ($this->getUser() == null || $this->getUser()->getRol() != 'ROLE_ADMIN' || $this->getUser()->getPermisoId() != 0) { return $this->redirectToRoute("page_not_found"); } $em = $this->getDoctrine()->getEntityManager(); $obispo_repo = $em->getRepository('SIICBundle:Obispo'); $obispo = $obispo_repo->findOneBy(array( 'id' => $id )); $obispo->setStatus(0); $em->persist($obispo); $flush = $em->flush(); if ($flush == null) { $status = array( 'message' => 'El obispo fue eliminado correctamente', 'type' => 'success' ); } else { $status = array( 'message' => 'El obispo no pudo ser eliminado', 'type' => 'error' ); } $this->session->getFlashBag()->add('status', $status); return $this->redirectToRoute("obispo_view_all"); } /* * API */ /* * Obtener todos los obispos por tipo */ public function getObisposByTypeAction(Request $request, $type) { $helpers = $this->get("app.helpers"); $em = $this->getDoctrine()->getEntityManager(); $obispo_repo = $em->getRepository('SIICBundle:Obispo'); $obispos = $obispo_repo->getObispoByType($type); $data = array( "status" => "error", "code" => 400, "msg" => "No existe ningun obispo", "data" => [] ); if ($obispos) { $data = array( "status" => "success", "code" => 200, "msg" => 'Correcto', "data" => $obispos ); } else { $data = array( "status" => "error", "code" => 400, "msg" => "No existe ningun obispo", "data" => [] ); } return $helpers->toJson($data); } /* * Obtener todos los obispos por if */ public function getObisposByIdAction(Request $request, $id) { $helpers = $this->get("app.helpers"); $em = $this->getDoctrine()->getEntityManager(); $obispo_repo = $em->getRepository('SIICBundle:Obispo'); $obispo = $obispo_repo->findOneBy(array( 'id' => $id, 'status' => 1 )); $data = array( "status" => "error", "code" => 400, "msg" => "No existe el obispo", "data" => [] ); if ($obispo) { $data = array( "status" => "success", "code" => 200, "msg" => 'Correcto', "data" => $obispo ); } else { $data = array( "status" => "error", "code" => 400, "msg" => "No existe el obispo", "data" => [] ); } return $helpers->toJson($data); } }
{ "content_hash": "b5ba65a9cb1aeeda3b8553b19cf721ce", "timestamp": "", "source": "github", "line_count": 406, "max_line_length": 126, "avg_line_length": 36.19458128078818, "alnum_prop": 0.5087444709084723, "repo_name": "Drixmux/siic", "id": "e28a13f4a5adac0cd1ccdcb7dd9491d8d20dd392", "size": "14697", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/SIICBundle/Controller/ObispoController.php", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "505720" }, { "name": "Gherkin", "bytes": "4937" }, { "name": "HTML", "bytes": "1629913" }, { "name": "JavaScript", "bytes": "1426164" }, { "name": "PHP", "bytes": "733911" }, { "name": "TypeScript", "bytes": "52583" } ] }
<?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright 2014 Open Networking Laboratory ~ ~ 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. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onosproject</groupId> <artifactId>onos-of-providers</artifactId> <version>1.2.2</version> <relativePath>../pom.xml</relativePath> </parent> <artifactId>onos-of-provider-flow</artifactId> <packaging>bundle</packaging> <description>ONOS OpenFlow protocol flow provider</description> <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> </dependency> </dependencies> </project>
{ "content_hash": "c4cdd6fb957a5ad23ebd29bde2e5d980", "timestamp": "", "source": "github", "line_count": 40, "max_line_length": 105, "avg_line_length": 36.85, "alnum_prop": 0.6777476255088195, "repo_name": "jmiserez/onos", "id": "d50f26c4ef5b8c205c2dc1e5a1b52dc5ffd5c355", "size": "1474", "binary": false, "copies": "1", "ref": "refs/heads/hb", "path": "providers/openflow/flow/pom.xml", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "162817" }, { "name": "HTML", "bytes": "473272" }, { "name": "Java", "bytes": "14472824" }, { "name": "JavaScript", "bytes": "3040821" }, { "name": "Shell", "bytes": "2625" } ] }
<?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright 2015 Red Hat, Inc. and/or its affiliates. ~ ~ 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. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.uberfire</groupId> <artifactId>uberfire-showcase</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> <artifactId>uberfire-client-webapp</artifactId> <packaging>war</packaging> <name>UberFire Showcase Client Only WebApp</name> <description>UberFire Showcase Client Only WebApp</description> <dependencies> <dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-client</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-workbench-client-views-patternfly</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-workbench-processors</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-io</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-ext</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-preferences-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-preferences-client</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <configuration> <module>org.uberfire.FastCompiledUberfireShowcaseClient</module> <logLevel>INFO</logLevel> <strict>true</strict> <runTarget>index.html</runTarget> <extraJvmArgs>-Xmx712m -XX:CompileThreshold=7000</extraJvmArgs> <compileSourcesArtifacts> <compileSourcesArtifact>org.uberfire:uberfire-commons</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-nio2-model</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-io</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-api</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-backend-api</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-preferences-api</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-preferences-client</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-security-api</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-js</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-security-client</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-client-api</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-workbench-client</compileSourcesArtifact> <compileSourcesArtifact>org.uberfire:uberfire-workbench-client-views-patternfly</compileSourcesArtifact> </compileSourcesArtifacts> </configuration> <executions> <execution> <id>gwt-clean</id> <phase>clean</phase> <goals> <goal>clean</goal> </goals> </execution> <execution> <id>gwt-compile</id> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>fullProfile</id> <activation> <property> <name>full</name> </property> </activation> <build> <plugins> <plugin><!-- Keep in sync with soa profile --> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <configuration> <!-- Build all GWT permutations and optimize them --> <module>org.uberfire.UberfireShowcaseClient</module> <draftCompile>false</draftCompile> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>
{ "content_hash": "3c4cebef0aa1580953de311ea6cf4971", "timestamp": "", "source": "github", "line_count": 167, "max_line_length": 116, "avg_line_length": 34.30538922155689, "alnum_prop": 0.6533426426950603, "repo_name": "mbiarnes/uberfire", "id": "6874e02ebdc31fff5fb814367c515cf110b2bf29", "size": "5729", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "uberfire-showcase/uberfire-client-webapp/pom.xml", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "74059" }, { "name": "FreeMarker", "bytes": "46611" }, { "name": "HTML", "bytes": "91730" }, { "name": "Java", "bytes": "13131230" }, { "name": "JavaScript", "bytes": "85658" }, { "name": "Shell", "bytes": "5830" } ] }
package es.um.nosql.s13e.entitydifferentiation.util; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.xmi.XMIResource; import es.um.nosql.s13e.entitydifferentiation.EntityDifferentiation.EntityDifferentiation; import es.um.nosql.s13e.entitydifferentiation.EntityDifferentiation.EntityDifferentiationPackage; import es.um.nosql.s13e.NoSQLSchema.NoSQLSchemaPackage; import es.um.nosql.s13e.util.ResourceManager; public class EntityDifferentiationWriter { private ResourceSet resourceSet; private Map<Object, Object> options; public EntityDifferentiationWriter() { resourceSet = new ResourceManager(NoSQLSchemaPackage.eINSTANCE, EntityDifferentiationPackage.eINSTANCE).getResourceSet(); NoSQLSchemaPackage.eINSTANCE.eResource().setURI(URI.createPlatformResourceURI("es.um.nosql.s13e/model/nosqlschema.ecore", true)); EntityDifferentiationPackage.eINSTANCE.eResource().setURI(URI.createPlatformResourceURI("es.um.nosql.s13e.entitydifferentiation/model/entitydifferentiation.ecore", true)); options = new HashMap<Object, Object>(); options.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); options.put(XMIResource.OPTION_ENCODING, "UTF-8"); } public void write(EntityDifferentiation eDiffModel, String outputRoute) { Resource outputRes = resourceSet.createResource(URI.createFileURI(outputRoute)); outputRes.getContents().add(eDiffModel); try { outputRes.save(new FileOutputStream(outputRoute), options); } catch (IOException e) { e.printStackTrace(); } } }
{ "content_hash": "fb238e71c41fecd57be22d0c6962952e", "timestamp": "", "source": "github", "line_count": 46, "max_line_length": 175, "avg_line_length": 38.54347826086956, "alnum_prop": 0.7941342357586012, "repo_name": "catedrasaes-umu/NoSQLDataEngineering", "id": "83d6e1eec82f40e8488a2a8502ca41eb050987f4", "size": "1773", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "projects/es.um.nosql.s13e.entitydifferentiation/src/es/um/nosql/s13e/entitydifferentiation/util/EntityDifferentiationWriter.java", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "17640" }, { "name": "HTML", "bytes": "14350" }, { "name": "Java", "bytes": "2794207" }, { "name": "JavaScript", "bytes": "912677" }, { "name": "Jupyter Notebook", "bytes": "481971" }, { "name": "Python", "bytes": "5269" }, { "name": "Scala", "bytes": "133995" }, { "name": "Shell", "bytes": "14112" }, { "name": "Xtend", "bytes": "780980" } ] }
This is a device type for the Sharp Aquos integration to SmartThings. I believe it actually works with almost all Sharp TV models manufacturered since 2010. <img src='http://ecx.images-amazon.com/images/I/81NwfXtTSyL._SX522_.jpg'> I loosely based this on <a href='https://github.com/halkeye/sharp.aquos.devicetype.groovy'>Gavin Mogan's Sharp Remote</a>. Most of the commands I found from a <a href='http://snpi.dell.com/sna/manuals/A1534250.pdf'>Sharp manual</a>. If you wish to programmatically access this device, it should accept most of the standard capabilities. However, I also added a capability and command that I am trying to get SmartThings to accept: inputSelect(). If you would like to switch inputs to input 1, for example, you would send inputSelect(1) ##Potential Bugs SmartThings does not have the ability to parse return values from the Sharp console. Thus, the state of the device is kept internal to the SmartThings device, and may drift from reality. In addition, you can only send one command every 8 seconds. I wrote some blocking code to prevent the device from drifting quickly, but if you send more than 3 commands in a 20 second window you will definitely drift. I had to hardcode the inputs you'd like to select on line 92. I only use input "1" and "2". You'll have to update this for your own taste, as SmartThings will not let us pick an array from device preference() As a last note, if you want to increase the reliability of the device, remove the login and password from your Sharp Network TV settings. ##License Copyright (c) 2015, Kristopher Kubicki All rights reserved.
{ "content_hash": "187a476b759d29938724f926180dd44c", "timestamp": "", "source": "github", "line_count": 20, "max_line_length": 305, "avg_line_length": 81.35, "alnum_prop": 0.7744314689612785, "repo_name": "KristopherKubicki/device-sharp-aquos", "id": "ce9bbebc7f0e8e06d742cbd903a692af4d48d8ee", "size": "1653", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "README.md", "mode": "33188", "license": "mit", "language": [ { "name": "Groovy", "bytes": "5278" } ] }
<!doctype html> <html> <head> <title>jsPlumb 1.3.12 - State Machine Demonstration - YUI3</title> <link rel="stylesheet" href="../css/jsPlumbDemo.css"> <link rel="stylesheet" href="../css/stateMachineDemo.css"> </head> <body onunload="jsPlumb.unload()" data-demo-id="stateMachineDemo" data-library="yui3"> <div style="position:absolute"> <div id="demo"> <div class="w" id="opened">begin<div class="ep"></div></div> <div class="w" id="olga">phone interview 1<div class="ep"></div></div> <div class="w" id="nicola">phone interview 2<div class="ep"></div></div> <div class="w" id="inperson">in person<div class="ep"></div></div> <div class="w" id="rejected">rejected<div class="ep"></div></div> </div> </div> <div id="explanation"> <p>This is a demonstration of the StateMachine connector type, and of 'Continuous' anchors, which are anchors whose location is calculated based on the location of all other connected elements. </p> <p>These behave in a similar way to 'Dynamic' anchors, which have been in jsPlumb for a while now, but Continuous anchors do not require a list of possible locations, and they guarantee that every Connection has its own anchor. </p> <p>Click and drag new Connections from the red div in each element; the main elements in the UI are configured to be Connection targets. You can drag from one of these divs onto its parent element to create a 'loopback' connection.</p> <p>Click on a Connection to delete it.</p> <p>makeSource is used in a special way in this demonstration: it is provided with a 'parent' parameter, which tells jsPlumb which element should be the eventual source of a newly created connection. So although you drag from the red divs, the connection sources are always configured to be the main divs in the UI.</p> <p>This demonstration uses jsPlumb 1.3.12 and YUI 3.3.0.</p> </div> <script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/simpleyui/simpleyui-min.js"></script> <script type='text/javascript' src='../js/yui.jsPlumb-1.3.12-all-min.js'></script> <!-- demo code --> <script type="text/javascript" src="../js/stateMachineDemo.js"></script> <script type="text/javascript" src="../js/stateMachineDemo-yui3.js"></script> <script type="text/javascript" src="../js/demo-list.js"></script> <script type="text/javascript" src="../js/demo-helper-yui3.js"></script> </body> </html>
{ "content_hash": "83332097f5cb359ad2c85b94a09b227a", "timestamp": "", "source": "github", "line_count": 47, "max_line_length": 161, "avg_line_length": 54.97872340425532, "alnum_prop": 0.6617647058823529, "repo_name": "doubleblacktech/learn-plumb", "id": "494c284776a8d953d4dc78b3843345c40786c6b9", "size": "2585", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "archive/1.3.12/demo/yui3/stateMachineDemo.html", "mode": "33261", "license": "mit", "language": [ { "name": "JavaScript", "bytes": "65950687" } ] }
<?php namespace Amazon\Pay\Model\Customer; use Amazon\Pay\Api\Data\AmazonCustomerInterface; use Magento\Customer\Api\Data\CustomerInterface; /** * @api */ interface MatcherInterface { /** * Match magento customer using amazon customer * * @param AmazonCustomerInterface $amazonCustomer * * @return CustomerInterface|null */ public function match(AmazonCustomerInterface $amazonCustomer); }
{ "content_hash": "26167a9193f3916ee3b09811e3847bb6", "timestamp": "", "source": "github", "line_count": 21, "max_line_length": 67, "avg_line_length": 20.61904761904762, "alnum_prop": 0.7159353348729792, "repo_name": "amzn/amazon-payments-magento-2-plugin", "id": "fcaab110cf76bffad40f738a0a49e3a559620016", "size": "1011", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "Model/Customer/MatcherInterface.php", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "146" }, { "name": "HTML", "bytes": "35051" }, { "name": "JavaScript", "bytes": "90269" }, { "name": "Less", "bytes": "11109" }, { "name": "PHP", "bytes": "461745" } ] }
module BABYLON { var maxSimultaneousLights = 4; class PBRMaterialDefines extends MaterialDefines { public ALBEDO = false; public AMBIENT = false; public OPACITY = false; public OPACITYRGB = false; public REFLECTION = false; public EMISSIVE = false; public REFLECTIVITY = false; public BUMP = false; public PARALLAX = false; public PARALLAXOCCLUSION = false; public SPECULAROVERALPHA = false; public CLIPPLANE = false; public ALPHATEST = false; public ALPHAFROMALBEDO = false; public POINTSIZE = false; public FOG = false; public LIGHT0 = false; public LIGHT1 = false; public LIGHT2 = false; public LIGHT3 = false; public SPOTLIGHT0 = false; public SPOTLIGHT1 = false; public SPOTLIGHT2 = false; public SPOTLIGHT3 = false; public HEMILIGHT0 = false; public HEMILIGHT1 = false; public HEMILIGHT2 = false; public HEMILIGHT3 = false; public POINTLIGHT0 = false; public POINTLIGHT1 = false; public POINTLIGHT2 = false; public POINTLIGHT3 = false; public DIRLIGHT0 = false; public DIRLIGHT1 = false; public DIRLIGHT2 = false; public DIRLIGHT3 = false; public SPECULARTERM = false; public SHADOW0 = false; public SHADOW1 = false; public SHADOW2 = false; public SHADOW3 = false; public SHADOWS = false; public SHADOWVSM0 = false; public SHADOWVSM1 = false; public SHADOWVSM2 = false; public SHADOWVSM3 = false; public SHADOWPCF0 = false; public SHADOWPCF1 = false; public SHADOWPCF2 = false; public SHADOWPCF3 = false; public OPACITYFRESNEL = false; public EMISSIVEFRESNEL = false; public FRESNEL = false; public NORMAL = false; public UV1 = false; public UV2 = false; public VERTEXCOLOR = false; public VERTEXALPHA = false; public NUM_BONE_INFLUENCERS = 0; public BonesPerMesh = 0; public INSTANCES = false; public MICROSURFACEFROMREFLECTIVITYMAP = false; public MICROSURFACEAUTOMATIC = false; public EMISSIVEASILLUMINATION = false; public LINKEMISSIVEWITHALBEDO = false; public LIGHTMAP = false; public USELIGHTMAPASSHADOWMAP = false; public REFLECTIONMAP_3D = false; public REFLECTIONMAP_SPHERICAL = false; public REFLECTIONMAP_PLANAR = false; public REFLECTIONMAP_CUBIC = false; public REFLECTIONMAP_PROJECTION = false; public REFLECTIONMAP_SKYBOX = false; public REFLECTIONMAP_EXPLICIT = false; public REFLECTIONMAP_EQUIRECTANGULAR = false; public INVERTCUBICMAP = false; public LOGARITHMICDEPTH = false; public CAMERATONEMAP = false; public CAMERACONTRAST = false; public OVERLOADEDVALUES = false; public OVERLOADEDSHADOWVALUES = false; public USESPHERICALFROMREFLECTIONMAP = false; public REFRACTION = false; public REFRACTIONMAP_3D = false; public LINKREFRACTIONTOTRANSPARENCY = false; public REFRACTIONMAPINLINEARSPACE = false; public LODBASEDMICROSFURACE = false; public USEPHYSICALLIGHTFALLOFF = false; public RADIANCEOVERALPHA = false; public USEPMREMREFLECTION = false; public USEPMREMREFRACTION = false; constructor() { super(); this._keys = Object.keys(this); } } /** * The Physically based material of BJS. * * This offers the main features of a standard PBR material. * For more information, please refer to the documentation : * http://doc.babylonjs.com/extensions/Physically_Based_Rendering */ export class PBRMaterial extends BABYLON.Material { /** * Intensity of the direct lights e.g. the four lights available in your scene. * This impacts both the direct diffuse and specular highlights. */ @serialize() public directIntensity: number = 1.0; /** * Intensity of the emissive part of the material. * This helps controlling the emissive effect without modifying the emissive color. */ @serialize() public emissiveIntensity: number = 1.0; /** * Intensity of the environment e.g. how much the environment will light the object * either through harmonics for rough material or through the refelction for shiny ones. */ @serialize() public environmentIntensity: number = 1.0; /** * This is a special control allowing the reduction of the specular highlights coming from the * four lights of the scene. Those highlights may not be needed in full environment lighting. */ @serialize() public specularIntensity: number = 1.0; private _lightingInfos: Vector4 = new Vector4(this.directIntensity, this.emissiveIntensity, this.environmentIntensity, this.specularIntensity); /** * Debug Control allowing disabling the bump map on this material. */ @serialize() public disableBumpMap: boolean = false; /** * Debug Control helping enforcing or dropping the darkness of shadows. * 1.0 means the shadows have their normal darkness, 0.0 means the shadows are not visible. */ @serialize() public overloadedShadowIntensity: number = 1.0; /** * Debug Control helping dropping the shading effect coming from the diffuse lighting. * 1.0 means the shade have their normal impact, 0.0 means no shading at all. */ @serialize() public overloadedShadeIntensity: number = 1.0; private _overloadedShadowInfos: Vector4 = new Vector4(this.overloadedShadowIntensity, this.overloadedShadeIntensity, 0.0, 0.0); /** * The camera exposure used on this material. * This property is here and not in the camera to allow controlling exposure without full screen post process. * This corresponds to a photographic exposure. */ @serialize() public cameraExposure: number = 1.0; /** * The camera contrast used on this material. * This property is here and not in the camera to allow controlling contrast without full screen post process. */ @serialize() public cameraContrast: number = 1.0; private _cameraInfos: Vector4 = new Vector4(1.0, 1.0, 0.0, 0.0); private _microsurfaceTextureLods: Vector2 = new Vector2(0.0, 0.0); /** * Debug Control allowing to overload the ambient color. * This as to be use with the overloadedAmbientIntensity parameter. */ @serializeAsColor3() public overloadedAmbient: Color3 = BABYLON.Color3.White(); /** * Debug Control indicating how much the overloaded ambient color is used against the default one. */ @serialize() public overloadedAmbientIntensity: number = 0.0; /** * Debug Control allowing to overload the albedo color. * This as to be use with the overloadedAlbedoIntensity parameter. */ @serializeAsColor3() public overloadedAlbedo: Color3 = BABYLON.Color3.White(); /** * Debug Control indicating how much the overloaded albedo color is used against the default one. */ @serialize() public overloadedAlbedoIntensity: number = 0.0; /** * Debug Control allowing to overload the reflectivity color. * This as to be use with the overloadedReflectivityIntensity parameter. */ @serializeAsColor3() public overloadedReflectivity: Color3 = new BABYLON.Color3(0.3, 0.3, 0.3); /** * Debug Control indicating how much the overloaded reflectivity color is used against the default one. */ @serialize() public overloadedReflectivityIntensity: number = 0.0; /** * Debug Control allowing to overload the emissive color. * This as to be use with the overloadedEmissiveIntensity parameter. */ @serializeAsColor3() public overloadedEmissive: Color3 = BABYLON.Color3.White(); /** * Debug Control indicating how much the overloaded emissive color is used against the default one. */ @serialize() public overloadedEmissiveIntensity: number = 0.0; private _overloadedIntensity: Vector4 = new Vector4(this.overloadedAmbientIntensity, this.overloadedAlbedoIntensity, this.overloadedReflectivityIntensity, this.overloadedEmissiveIntensity); /** * Debug Control allowing to overload the reflection color. * This as to be use with the overloadedReflectionIntensity parameter. */ @serializeAsColor3() public overloadedReflection: Color3 = BABYLON.Color3.White(); /** * Debug Control indicating how much the overloaded reflection color is used against the default one. */ @serialize() public overloadedReflectionIntensity: number = 0.0; /** * Debug Control allowing to overload the microsurface. * This as to be use with the overloadedMicroSurfaceIntensity parameter. */ @serialize() public overloadedMicroSurface: number = 0.0; /** * Debug Control indicating how much the overloaded microsurface is used against the default one. */ @serialize() public overloadedMicroSurfaceIntensity: number = 0.0; private _overloadedMicroSurface: Vector3 = new Vector3(this.overloadedMicroSurface, this.overloadedMicroSurfaceIntensity, this.overloadedReflectionIntensity); /** * AKA Diffuse Texture in standard nomenclature. */ @serializeAsTexture() public albedoTexture: BaseTexture; /** * AKA Occlusion Texture in other nomenclature. */ @serializeAsTexture() public ambientTexture: BaseTexture; @serializeAsTexture() public opacityTexture: BaseTexture; @serializeAsTexture() public reflectionTexture: BaseTexture; @serializeAsTexture() public emissiveTexture: BaseTexture; /** * AKA Specular texture in other nomenclature. */ @serializeAsTexture() public reflectivityTexture: BaseTexture; @serializeAsTexture() public bumpTexture: BaseTexture; @serializeAsTexture() public lightmapTexture: BaseTexture; @serializeAsTexture() public refractionTexture: BaseTexture; @serializeAsColor3("ambient") public ambientColor = new Color3(0, 0, 0); /** * AKA Diffuse Color in other nomenclature. */ @serializeAsColor3("albedo") public albedoColor = new Color3(1, 1, 1); /** * AKA Specular Color in other nomenclature. */ @serializeAsColor3("reflectivity") public reflectivityColor = new Color3(1, 1, 1); @serializeAsColor3("reflection") public reflectionColor = new Color3(0.5, 0.5, 0.5); @serializeAsColor3("emissive") public emissiveColor = new Color3(0, 0, 0); /** * AKA Glossiness in other nomenclature. */ @serialize() public microSurface = 0.9; /** * source material index of refraction (IOR)' / 'destination material IOR. */ @serialize() public indexOfRefraction = 0.66; /** * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture. */ @serialize() public invertRefractionY = false; @serializeAsFresnelParameters() public opacityFresnelParameters: FresnelParameters; @serializeAsFresnelParameters() public emissiveFresnelParameters: FresnelParameters; /** * This parameters will make the material used its opacity to control how much it is refracting aginst not. * Materials half opaque for instance using refraction could benefit from this control. */ @serialize() public linkRefractionWithTransparency = false; /** * The emissive and albedo are linked to never be more than one (Energy conservation). */ @serialize() public linkEmissiveWithAlbedo = false; @serialize() public useLightmapAsShadowmap = false; /** * In this mode, the emissive informtaion will always be added to the lighting once. * A light for instance can be thought as emissive. */ @serialize() public useEmissiveAsIllumination = false; /** * Secifies that the alpha is coming form the albedo channel alpha channel. */ @serialize() public useAlphaFromAlbedoTexture = false; /** * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones). * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind. */ @serialize() public useSpecularOverAlpha = true; /** * Specifies if the reflectivity texture contains the glossiness information in its alpha channel. */ @serialize() public useMicroSurfaceFromReflectivityMapAlpha = false; /** * In case the reflectivity map does not contain the microsurface information in its alpha channel, * The material will try to infer what glossiness each pixel should be. */ @serialize() public useAutoMicroSurfaceFromReflectivityMap = false; /** * Allows to work with scalar in linear mode. This is definitely a matter of preferences and tools used during * the creation of the material. */ @serialize() public useScalarInLinearSpace = false; /** * BJS is using an harcoded light falloff based on a manually sets up range. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. */ @serialize() public usePhysicalLightFalloff = true; /** * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. */ @serialize() public useRadianceOverAlpha = true; /** * Allows using the bump map in parallax mode. */ @serialize() public useParallax = false; /** * Allows using the bump map in parallax occlusion mode. */ @serialize() public useParallaxOcclusion = false; /** * Controls the scale bias of the parallax mode. */ @serialize() public parallaxScaleBias = 0.05; @serialize() public disableLighting = false; private _renderTargets = new SmartArray<RenderTargetTexture>(16); private _worldViewProjectionMatrix = Matrix.Zero(); private _globalAmbientColor = new Color3(0, 0, 0); private _tempColor = new Color3(); private _renderId: number; private _defines = new PBRMaterialDefines(); private _cachedDefines = new PBRMaterialDefines(); private _useLogarithmicDepth: boolean; /** * Instantiates a new PBRMaterial instance. * * @param name The material name * @param scene The scene the material will be use in. */ constructor(name: string, scene: Scene) { super(name, scene); this._cachedDefines.BonesPerMesh = -1; this.getRenderTargetTextures = (): SmartArray<RenderTargetTexture> => { this._renderTargets.reset(); if (this.reflectionTexture && this.reflectionTexture.isRenderTarget) { this._renderTargets.push(this.reflectionTexture); } if (this.refractionTexture && this.refractionTexture.isRenderTarget) { this._renderTargets.push(this.refractionTexture); } return this._renderTargets; } } @serialize() public get useLogarithmicDepth(): boolean { return this._useLogarithmicDepth; } public set useLogarithmicDepth(value: boolean) { this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported; } public needAlphaBlending(): boolean { if (this.linkRefractionWithTransparency) { return false; } return (this.alpha < 1.0) || (this.opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture() || this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled; } public needAlphaTesting(): boolean { if (this.linkRefractionWithTransparency) { return false; } return this.albedoTexture != null && this.albedoTexture.hasAlpha; } private _shouldUseAlphaFromAlbedoTexture(): boolean { return this.albedoTexture != null && this.albedoTexture.hasAlpha && this.useAlphaFromAlbedoTexture; } public getAlphaTestTexture(): BaseTexture { return this.albedoTexture; } private _checkCache(scene: Scene, mesh?: AbstractMesh, useInstances?: boolean): boolean { if (!mesh) { return true; } if (this._defines.INSTANCES !== useInstances) { return false; } if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) { return true; } return false; } private convertColorToLinearSpaceToRef(color: Color3, ref: Color3): void { PBRMaterial.convertColorToLinearSpaceToRef(color, ref, this.useScalarInLinearSpace); } private static convertColorToLinearSpaceToRef(color: Color3, ref: Color3, useScalarInLinear: boolean): void { if (!useScalarInLinear) { color.toLinearSpaceToRef(ref); } else { ref.r = color.r; ref.g = color.g; ref.b = color.b; } } private static _scaledAlbedo = new Color3(); private static _scaledReflectivity = new Color3(); private static _scaledEmissive = new Color3(); private static _scaledReflection = new Color3(); private static _lightRadiuses = [1, 1, 1, 1]; public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean) { var lightIndex = 0; var depthValuesAlreadySet = false; for (var index = 0; index < scene.lights.length; index++) { var light = scene.lights[index]; if (!light.isEnabled()) { continue; } if (!light.canAffectMesh(mesh)) { continue; } this._lightRadiuses[lightIndex] = light.radius; MaterialHelper.BindLightProperties(light, effect, lightIndex); // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(light.diffuse, PBRMaterial._scaledAlbedo, useScalarInLinearSpace); PBRMaterial._scaledAlbedo.scaleToRef(light.intensity, PBRMaterial._scaledAlbedo); effect.setColor4("vLightDiffuse" + lightIndex, PBRMaterial._scaledAlbedo, light.range); if (defines["SPECULARTERM"]) { this.convertColorToLinearSpaceToRef(light.specular, PBRMaterial._scaledReflectivity, useScalarInLinearSpace); PBRMaterial._scaledReflectivity.scaleToRef(light.intensity, PBRMaterial._scaledReflectivity); effect.setColor3("vLightSpecular" + lightIndex, PBRMaterial._scaledReflectivity); } // Shadows if (scene.shadowsEnabled) { depthValuesAlreadySet = MaterialHelper.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet); } lightIndex++; if (lightIndex === maxSimultaneousLights) break; } effect.setFloat4("vLightRadiuses", this._lightRadiuses[0], this._lightRadiuses[1], this._lightRadiuses[2], this._lightRadiuses[3]); } public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean { if (this.checkReadyOnlyOnce) { if (this._wasPreviouslyReady) { return true; } } var scene = this.getScene(); if (!this.checkReadyOnEveryCall) { if (this._renderId === scene.getRenderId()) { if (this._checkCache(scene, mesh, useInstances)) { return true; } } } var engine = scene.getEngine(); var needNormals = false; var needUVs = false; this._defines.reset(); if (scene.texturesEnabled) { // Textures if (scene.texturesEnabled) { if (scene.getEngine().getCaps().textureLOD) { this._defines.LODBASEDMICROSFURACE = true; } if (this.albedoTexture && StandardMaterial.DiffuseTextureEnabled) { if (!this.albedoTexture.isReady()) { return false; } else { needUVs = true; this._defines.ALBEDO = true; } } if (this.ambientTexture && StandardMaterial.AmbientTextureEnabled) { if (!this.ambientTexture.isReady()) { return false; } else { needUVs = true; this._defines.AMBIENT = true; } } if (this.opacityTexture && StandardMaterial.OpacityTextureEnabled) { if (!this.opacityTexture.isReady()) { return false; } else { needUVs = true; this._defines.OPACITY = true; if (this.opacityTexture.getAlphaFromRGB) { this._defines.OPACITYRGB = true; } } } if (this.reflectionTexture && StandardMaterial.ReflectionTextureEnabled) { if (!this.reflectionTexture.isReady()) { return false; } else { needNormals = true; this._defines.REFLECTION = true; if (this.reflectionTexture.coordinatesMode === Texture.INVCUBIC_MODE) { this._defines.INVERTCUBICMAP = true; } this._defines.REFLECTIONMAP_3D = this.reflectionTexture.isCube; switch (this.reflectionTexture.coordinatesMode) { case Texture.CUBIC_MODE: case Texture.INVCUBIC_MODE: this._defines.REFLECTIONMAP_CUBIC = true; break; case Texture.EXPLICIT_MODE: this._defines.REFLECTIONMAP_EXPLICIT = true; break; case Texture.PLANAR_MODE: this._defines.REFLECTIONMAP_PLANAR = true; break; case Texture.PROJECTION_MODE: this._defines.REFLECTIONMAP_PROJECTION = true; break; case Texture.SKYBOX_MODE: this._defines.REFLECTIONMAP_SKYBOX = true; break; case Texture.SPHERICAL_MODE: this._defines.REFLECTIONMAP_SPHERICAL = true; break; case Texture.EQUIRECTANGULAR_MODE: this._defines.REFLECTIONMAP_EQUIRECTANGULAR = true; break; } if (this.reflectionTexture instanceof HDRCubeTexture && (<HDRCubeTexture>this.reflectionTexture)) { this._defines.USESPHERICALFROMREFLECTIONMAP = true; needNormals = true; if ((<HDRCubeTexture>this.reflectionTexture).isPMREM) { this._defines.USEPMREMREFLECTION = true; } } } } if (this.lightmapTexture && StandardMaterial.LightmapTextureEnabled) { if (!this.lightmapTexture.isReady()) { return false; } else { needUVs = true; this._defines.LIGHTMAP = true; this._defines.USELIGHTMAPASSHADOWMAP = this.useLightmapAsShadowmap; } } if (this.emissiveTexture && StandardMaterial.EmissiveTextureEnabled) { if (!this.emissiveTexture.isReady()) { return false; } else { needUVs = true; this._defines.EMISSIVE = true; } } if (this.reflectivityTexture && StandardMaterial.SpecularTextureEnabled) { if (!this.reflectivityTexture.isReady()) { return false; } else { needUVs = true; this._defines.REFLECTIVITY = true; this._defines.MICROSURFACEFROMREFLECTIVITYMAP = this.useMicroSurfaceFromReflectivityMapAlpha; this._defines.MICROSURFACEAUTOMATIC = this.useAutoMicroSurfaceFromReflectivityMap; } } } if (scene.getEngine().getCaps().standardDerivatives && this.bumpTexture && StandardMaterial.BumpTextureEnabled && !this.disableBumpMap) { if (!this.bumpTexture.isReady()) { return false; } else { needUVs = true; this._defines.BUMP = true; if (this.useParallax) { this._defines.PARALLAX = true; if (this.useParallaxOcclusion) { this._defines.PARALLAXOCCLUSION = true; } } } } if (this.refractionTexture && StandardMaterial.RefractionTextureEnabled) { if (!this.refractionTexture.isReady()) { return false; } else { needUVs = true; this._defines.REFRACTION = true; this._defines.REFRACTIONMAP_3D = this.refractionTexture.isCube; if (this.linkRefractionWithTransparency) { this._defines.LINKREFRACTIONTOTRANSPARENCY = true; } if (this.refractionTexture instanceof HDRCubeTexture) { this._defines.REFRACTIONMAPINLINEARSPACE = true; if ((<HDRCubeTexture>this.refractionTexture).isPMREM) { this._defines.USEPMREMREFRACTION = true; } } } } } // Effect if (scene.clipPlane) { this._defines.CLIPPLANE = true; } if (engine.getAlphaTesting()) { this._defines.ALPHATEST = true; } if (this._shouldUseAlphaFromAlbedoTexture()) { this._defines.ALPHAFROMALBEDO = true; } if (this.useEmissiveAsIllumination) { this._defines.EMISSIVEASILLUMINATION = true; } if (this.linkEmissiveWithAlbedo) { this._defines.LINKEMISSIVEWITHALBEDO = true; } if (this.useLogarithmicDepth) { this._defines.LOGARITHMICDEPTH = true; } if (this.cameraContrast != 1) { this._defines.CAMERACONTRAST = true; } if (this.cameraExposure != 1) { this._defines.CAMERATONEMAP = true; } if (this.overloadedShadeIntensity != 1 || this.overloadedShadowIntensity != 1) { this._defines.OVERLOADEDSHADOWVALUES = true; } if (this.overloadedMicroSurfaceIntensity > 0 || this.overloadedEmissiveIntensity > 0 || this.overloadedReflectivityIntensity > 0 || this.overloadedAlbedoIntensity > 0 || this.overloadedAmbientIntensity > 0 || this.overloadedReflectionIntensity > 0) { this._defines.OVERLOADEDVALUES = true; } // Point size if (this.pointsCloud || scene.forcePointsCloud) { this._defines.POINTSIZE = true; } // Fog if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) { this._defines.FOG = true; } if (scene.lightsEnabled && !this.disableLighting) { needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, this._defines) || needNormals; } if (StandardMaterial.FresnelEnabled) { // Fresnel if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled || this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) { if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) { this._defines.OPACITYFRESNEL = true; } if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) { this._defines.EMISSIVEFRESNEL = true; } needNormals = true; this._defines.FRESNEL = true; } } if (this._defines.SPECULARTERM && this.useSpecularOverAlpha) { this._defines.SPECULAROVERALPHA = true; } if (this.usePhysicalLightFalloff) { this._defines.USEPHYSICALLIGHTFALLOFF = true; } if (this.useRadianceOverAlpha) { this._defines.RADIANCEOVERALPHA = true; } // Attribs if (mesh) { if (needNormals && mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) { this._defines.NORMAL = true; } if (needUVs) { if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) { this._defines.UV1 = true; } if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) { this._defines.UV2 = true; } } if (mesh.useVertexColors && mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) { this._defines.VERTEXCOLOR = true; if (mesh.hasVertexAlpha) { this._defines.VERTEXALPHA = true; } } if (mesh.useBones && mesh.computeBonesUsingShaders) { this._defines.NUM_BONE_INFLUENCERS = mesh.numBoneInfluencers; this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1); } // Instances if (useInstances) { this._defines.INSTANCES = true; } } // Get correct effect if (!this._defines.isEqual(this._cachedDefines)) { this._defines.cloneTo(this._cachedDefines); scene.resetCachedMaterial(); // Fallbacks var fallbacks = new EffectFallbacks(); if (this._defines.REFLECTION) { fallbacks.addFallback(0, "REFLECTION"); } if (this._defines.REFRACTION) { fallbacks.addFallback(0, "REFRACTION"); } if (this._defines.REFLECTIVITY) { fallbacks.addFallback(0, "REFLECTIVITY"); } if (this._defines.BUMP) { fallbacks.addFallback(0, "BUMP"); } if (this._defines.PARALLAX) { fallbacks.addFallback(1, "PARALLAX"); } if (this._defines.PARALLAXOCCLUSION) { fallbacks.addFallback(0, "PARALLAXOCCLUSION"); } if (this._defines.SPECULAROVERALPHA) { fallbacks.addFallback(0, "SPECULAROVERALPHA"); } if (this._defines.FOG) { fallbacks.addFallback(1, "FOG"); } if (this._defines.POINTSIZE) { fallbacks.addFallback(0, "POINTSIZE"); } if (this._defines.LOGARITHMICDEPTH) { fallbacks.addFallback(0, "LOGARITHMICDEPTH"); } MaterialHelper.HandleFallbacksForShadows(this._defines, fallbacks); if (this._defines.SPECULARTERM) { fallbacks.addFallback(0, "SPECULARTERM"); } if (this._defines.OPACITYFRESNEL) { fallbacks.addFallback(1, "OPACITYFRESNEL"); } if (this._defines.EMISSIVEFRESNEL) { fallbacks.addFallback(2, "EMISSIVEFRESNEL"); } if (this._defines.FRESNEL) { fallbacks.addFallback(3, "FRESNEL"); } if (this._defines.NUM_BONE_INFLUENCERS > 0) { fallbacks.addCPUSkinningFallback(0, mesh); } //Attributes var attribs = [VertexBuffer.PositionKind]; if (this._defines.NORMAL) { attribs.push(VertexBuffer.NormalKind); } if (this._defines.UV1) { attribs.push(VertexBuffer.UVKind); } if (this._defines.UV2) { attribs.push(VertexBuffer.UV2Kind); } if (this._defines.VERTEXCOLOR) { attribs.push(VertexBuffer.ColorKind); } MaterialHelper.PrepareAttributesForBones(attribs, mesh, this._defines, fallbacks); MaterialHelper.PrepareAttributesForInstances(attribs, this._defines); // Legacy browser patch var shaderName = "pbr"; if (!scene.getEngine().getCaps().standardDerivatives) { shaderName = "legacypbr"; } var join = this._defines.toString(); this._effect = scene.getEngine().createEffect(shaderName, attribs, ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor", "vLightData0", "vLightDiffuse0", "vLightSpecular0", "vLightDirection0", "vLightGround0", "lightMatrix0", "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1", "lightMatrix1", "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2", "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3", "lightMatrix3", "vFogInfos", "vFogColor", "pointSize", "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vReflectivityInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos", "mBones", "vClipPlane", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix", "shadowsInfo0", "shadowsInfo1", "shadowsInfo2", "shadowsInfo3", "depthValues", "opacityParts", "emissiveLeftColor", "emissiveRightColor", "vLightingIntensity", "vOverloadedShadowIntensity", "vOverloadedIntensity", "vCameraInfos", "vOverloadedAlbedo", "vOverloadedReflection", "vOverloadedReflectivity", "vOverloadedEmissive", "vOverloadedMicroSurface", "logarithmicDepthConstant", "vSphericalX", "vSphericalY", "vSphericalZ", "vSphericalXX", "vSphericalYY", "vSphericalZZ", "vSphericalXY", "vSphericalYZ", "vSphericalZX", "vMicrosurfaceTextureLods", "vLightRadiuses" ], ["albedoSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "reflectivitySampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3" ], join, fallbacks, this.onCompiled, this.onError); } if (!this._effect.isReady()) { return false; } this._renderId = scene.getRenderId(); this._wasPreviouslyReady = true; if (mesh) { if (!mesh._materialDefines) { mesh._materialDefines = new PBRMaterialDefines(); } this._defines.cloneTo(mesh._materialDefines); } return true; } public unbind(): void { if (this.reflectionTexture && this.reflectionTexture.isRenderTarget) { this._effect.setTexture("reflection2DSampler", null); } if (this.refractionTexture && this.refractionTexture.isRenderTarget) { this._effect.setTexture("refraction2DSampler", null); } super.unbind(); } public bindOnlyWorldMatrix(world: Matrix): void { this._effect.setMatrix("world", world); } private _myScene: BABYLON.Scene = null; private _myShadowGenerator: BABYLON.ShadowGenerator = null; public bind(world: Matrix, mesh?: Mesh): void { this._myScene = this.getScene(); // Matrices this.bindOnlyWorldMatrix(world); // Bones MaterialHelper.BindBonesParameters(mesh, this._effect); if (this._myScene.getCachedMaterial() !== (<BABYLON.Material>this)) { this._effect.setMatrix("viewProjection", this._myScene.getTransformMatrix()); if (StandardMaterial.FresnelEnabled) { if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) { this._effect.setColor4("opacityParts", new Color3(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power); } if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) { this._effect.setColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power); this._effect.setColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias); } } // Textures if (this._myScene.texturesEnabled) { if (this.albedoTexture && StandardMaterial.DiffuseTextureEnabled) { this._effect.setTexture("albedoSampler", this.albedoTexture); this._effect.setFloat2("vAlbedoInfos", this.albedoTexture.coordinatesIndex, this.albedoTexture.level); this._effect.setMatrix("albedoMatrix", this.albedoTexture.getTextureMatrix()); } if (this.ambientTexture && StandardMaterial.AmbientTextureEnabled) { this._effect.setTexture("ambientSampler", this.ambientTexture); this._effect.setFloat2("vAmbientInfos", this.ambientTexture.coordinatesIndex, this.ambientTexture.level); this._effect.setMatrix("ambientMatrix", this.ambientTexture.getTextureMatrix()); } if (this.opacityTexture && StandardMaterial.OpacityTextureEnabled) { this._effect.setTexture("opacitySampler", this.opacityTexture); this._effect.setFloat2("vOpacityInfos", this.opacityTexture.coordinatesIndex, this.opacityTexture.level); this._effect.setMatrix("opacityMatrix", this.opacityTexture.getTextureMatrix()); } if (this.reflectionTexture && StandardMaterial.ReflectionTextureEnabled) { this._microsurfaceTextureLods.x = Math.round(Math.log(this.reflectionTexture.getSize().width) * Math.LOG2E); if (this.reflectionTexture.isCube) { this._effect.setTexture("reflectionCubeSampler", this.reflectionTexture); } else { this._effect.setTexture("reflection2DSampler", this.reflectionTexture); } this._effect.setMatrix("reflectionMatrix", this.reflectionTexture.getReflectionTextureMatrix()); this._effect.setFloat2("vReflectionInfos", this.reflectionTexture.level, 0); if (this._defines.USESPHERICALFROMREFLECTIONMAP) { this._effect.setFloat3("vSphericalX", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.x.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.x.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.x.z); this._effect.setFloat3("vSphericalY", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.y.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.y.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.y.z); this._effect.setFloat3("vSphericalZ", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.z.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.z.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.z.z); this._effect.setFloat3("vSphericalXX", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xx.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xx.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xx.z); this._effect.setFloat3("vSphericalYY", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yy.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yy.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yy.z); this._effect.setFloat3("vSphericalZZ", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zz.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zz.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zz.z); this._effect.setFloat3("vSphericalXY", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xy.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xy.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xy.z); this._effect.setFloat3("vSphericalYZ", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yz.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yz.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yz.z); this._effect.setFloat3("vSphericalZX", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zx.x, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zx.y, (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zx.z); } } if (this.emissiveTexture && StandardMaterial.EmissiveTextureEnabled) { this._effect.setTexture("emissiveSampler", this.emissiveTexture); this._effect.setFloat2("vEmissiveInfos", this.emissiveTexture.coordinatesIndex, this.emissiveTexture.level); this._effect.setMatrix("emissiveMatrix", this.emissiveTexture.getTextureMatrix()); } if (this.lightmapTexture && StandardMaterial.LightmapTextureEnabled) { this._effect.setTexture("lightmapSampler", this.lightmapTexture); this._effect.setFloat2("vLightmapInfos", this.lightmapTexture.coordinatesIndex, this.lightmapTexture.level); this._effect.setMatrix("lightmapMatrix", this.lightmapTexture.getTextureMatrix()); } if (this.reflectivityTexture && StandardMaterial.SpecularTextureEnabled) { this._effect.setTexture("reflectivitySampler", this.reflectivityTexture); this._effect.setFloat2("vReflectivityInfos", this.reflectivityTexture.coordinatesIndex, this.reflectivityTexture.level); this._effect.setMatrix("reflectivityMatrix", this.reflectivityTexture.getTextureMatrix()); } if (this.bumpTexture && this._myScene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled && !this.disableBumpMap) { this._effect.setTexture("bumpSampler", this.bumpTexture); this._effect.setFloat3("vBumpInfos", this.bumpTexture.coordinatesIndex, 1.0 / this.bumpTexture.level, this.parallaxScaleBias); this._effect.setMatrix("bumpMatrix", this.bumpTexture.getTextureMatrix()); } if (this.refractionTexture && StandardMaterial.RefractionTextureEnabled) { this._microsurfaceTextureLods.y = Math.round(Math.log(this.refractionTexture.getSize().width) * Math.LOG2E); var depth = 1.0; if (this.refractionTexture.isCube) { this._effect.setTexture("refractionCubeSampler", this.refractionTexture); } else { this._effect.setTexture("refraction2DSampler", this.refractionTexture); this._effect.setMatrix("refractionMatrix", this.refractionTexture.getReflectionTextureMatrix()); if ((<any>this.refractionTexture).depth) { depth = (<any>this.refractionTexture).depth; } } this._effect.setFloat4("vRefractionInfos", this.refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1); } if ((this.reflectionTexture || this.refractionTexture)) { this._effect.setFloat2("vMicrosurfaceTextureLods", this._microsurfaceTextureLods.x, this._microsurfaceTextureLods.y); } } // Clip plane MaterialHelper.BindClipPlane(this._effect, this._myScene); // Point size if (this.pointsCloud) { this._effect.setFloat("pointSize", this.pointSize); } // Colors this._myScene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor); // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(this.reflectivityColor, PBRMaterial._scaledReflectivity); this._effect.setVector3("vEyePosition", this._myScene._mirroredCameraPosition ? this._myScene._mirroredCameraPosition : this._myScene.activeCamera.position); this._effect.setColor3("vAmbientColor", this._globalAmbientColor); this._effect.setColor4("vReflectivityColor", PBRMaterial._scaledReflectivity, this.microSurface); // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(this.emissiveColor, PBRMaterial._scaledEmissive); this._effect.setColor3("vEmissiveColor", PBRMaterial._scaledEmissive); // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(this.reflectionColor, PBRMaterial._scaledReflection); this._effect.setColor3("vReflectionColor", PBRMaterial._scaledReflection); } if (this._myScene.getCachedMaterial() !== this || !this.isFrozen) { // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(this.albedoColor, PBRMaterial._scaledAlbedo); this._effect.setColor4("vAlbedoColor", PBRMaterial._scaledAlbedo, this.alpha * mesh.visibility); // Lights if (this._myScene.lightsEnabled && !this.disableLighting) { PBRMaterial.BindLights(this._myScene, mesh, this._effect, this._defines, this.useScalarInLinearSpace); } // View if (this._myScene.fogEnabled && mesh.applyFog && this._myScene.fogMode !== Scene.FOGMODE_NONE || this.reflectionTexture) { this._effect.setMatrix("view", this._myScene.getViewMatrix()); } // Fog MaterialHelper.BindFogParameters(this._myScene, mesh, this._effect); this._lightingInfos.x = this.directIntensity; this._lightingInfos.y = this.emissiveIntensity; this._lightingInfos.z = this.environmentIntensity; this._lightingInfos.w = this.specularIntensity; this._effect.setVector4("vLightingIntensity", this._lightingInfos); this._overloadedShadowInfos.x = this.overloadedShadowIntensity; this._overloadedShadowInfos.y = this.overloadedShadeIntensity; this._effect.setVector4("vOverloadedShadowIntensity", this._overloadedShadowInfos); this._cameraInfos.x = this.cameraExposure; this._cameraInfos.y = this.cameraContrast; this._effect.setVector4("vCameraInfos", this._cameraInfos); this._overloadedIntensity.x = this.overloadedAmbientIntensity; this._overloadedIntensity.y = this.overloadedAlbedoIntensity; this._overloadedIntensity.z = this.overloadedReflectivityIntensity; this._overloadedIntensity.w = this.overloadedEmissiveIntensity; this._effect.setVector4("vOverloadedIntensity", this._overloadedIntensity); this.convertColorToLinearSpaceToRef(this.overloadedAmbient, this._tempColor); this._effect.setColor3("vOverloadedAmbient", this._tempColor); this.convertColorToLinearSpaceToRef(this.overloadedAlbedo, this._tempColor); this._effect.setColor3("vOverloadedAlbedo", this._tempColor); this.convertColorToLinearSpaceToRef(this.overloadedReflectivity, this._tempColor); this._effect.setColor3("vOverloadedReflectivity", this._tempColor); this.convertColorToLinearSpaceToRef(this.overloadedEmissive, this._tempColor); this._effect.setColor3("vOverloadedEmissive", this._tempColor); this.convertColorToLinearSpaceToRef(this.overloadedReflection, this._tempColor); this._effect.setColor3("vOverloadedReflection", this._tempColor); this._overloadedMicroSurface.x = this.overloadedMicroSurface; this._overloadedMicroSurface.y = this.overloadedMicroSurfaceIntensity; this._overloadedMicroSurface.z = this.overloadedReflectionIntensity; this._effect.setVector3("vOverloadedMicroSurface", this._overloadedMicroSurface); // Log. depth MaterialHelper.BindLogDepth(this._defines, this._effect, this._myScene); } super.bind(world, mesh); this._myScene = null; } public getAnimatables(): IAnimatable[] { var results = []; if (this.albedoTexture && this.albedoTexture.animations && this.albedoTexture.animations.length > 0) { results.push(this.albedoTexture); } if (this.ambientTexture && this.ambientTexture.animations && this.ambientTexture.animations.length > 0) { results.push(this.ambientTexture); } if (this.opacityTexture && this.opacityTexture.animations && this.opacityTexture.animations.length > 0) { results.push(this.opacityTexture); } if (this.reflectionTexture && this.reflectionTexture.animations && this.reflectionTexture.animations.length > 0) { results.push(this.reflectionTexture); } if (this.emissiveTexture && this.emissiveTexture.animations && this.emissiveTexture.animations.length > 0) { results.push(this.emissiveTexture); } if (this.reflectivityTexture && this.reflectivityTexture.animations && this.reflectivityTexture.animations.length > 0) { results.push(this.reflectivityTexture); } if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) { results.push(this.bumpTexture); } if (this.lightmapTexture && this.lightmapTexture.animations && this.lightmapTexture.animations.length > 0) { results.push(this.lightmapTexture); } if (this.refractionTexture && this.refractionTexture.animations && this.refractionTexture.animations.length > 0) { results.push(this.refractionTexture); } return results; } public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void { if (forceDisposeTextures) { if (this.albedoTexture) { this.albedoTexture.dispose(); } if (this.ambientTexture) { this.ambientTexture.dispose(); } if (this.opacityTexture) { this.opacityTexture.dispose(); } if (this.reflectionTexture) { this.reflectionTexture.dispose(); } if (this.emissiveTexture) { this.emissiveTexture.dispose(); } if (this.reflectivityTexture) { this.reflectivityTexture.dispose(); } if (this.bumpTexture) { this.bumpTexture.dispose(); } if (this.lightmapTexture) { this.lightmapTexture.dispose(); } if (this.refractionTexture) { this.refractionTexture.dispose(); } } super.dispose(forceDisposeEffect, forceDisposeTextures); } public clone(name: string): PBRMaterial { return SerializationHelper.Clone(() => new PBRMaterial(name, this.getScene()), this); } public serialize(): any { var serializationObject = SerializationHelper.Serialize(this); serializationObject.customType = "BABYLON.PBRMaterial"; return serializationObject; } // Statics public static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial { return SerializationHelper.Parse(() => new PBRMaterial(source.name, scene), source, scene, rootUrl); } } }
{ "content_hash": "9f82a7eaa6d2ca04b1c49f34ff0c43ef", "timestamp": "", "source": "github", "line_count": 1382, "max_line_length": 259, "avg_line_length": 43.240231548480466, "alnum_prop": 0.5574985775963051, "repo_name": "jjcollinge/DroneSimulation", "id": "c5b611e3a5e124048fbbb00cce28a9c33aa122f9", "size": "59760", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/DroneSim/WebApp/wwwroot/lib/babylonjs/src/Materials/babylon.pbrMaterial.ts", "mode": "33188", "license": "mit", "language": [ { "name": "C#", "bytes": "187779" }, { "name": "CSS", "bytes": "1414" }, { "name": "HLSL", "bytes": "274915" }, { "name": "HTML", "bytes": "40406" }, { "name": "JavaScript", "bytes": "17474585" }, { "name": "PowerShell", "bytes": "15998" }, { "name": "TypeScript", "bytes": "2147889" } ] }
End of preview.

No dataset card yet

Downloads last month
5